zoukankan      html  css  js  c++  java
  • C#

      string appPath = AppDomain.CurrentDomain.BaseDirectory + "NCDB.db";  //相对路径
    !string.IsNullOrEmpty(txtCostCenterCode.Text)
    A.托管代码是一种中间语言,运行在CLR上。
    A.非托管代码被编译为机器码,运行在机器上。
    B.托管代码独立与平台和语言,能更好的实现不同语言平台之间的兼容。
    B.非托管代码依赖于平台和语言。
    C.托管代码可是享受CLR提供的服务(安全检测,垃圾回收,)不需要自己完成这些操作
    C.非托管代码需要自己提供安全检测,垃圾回收等操作
    C:ProgramDataMicrosoft Visual Studio10.0
    dt.Rows.Count   判断datatable是否含有数据
    yyyy-MM-dd HH:mm:ss   转换成时间格式,注意各字母大小写
     public List<udt_mm_ComReceiveMat_Detailed> DQueryNow(string strWhere, int PageID)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("Select * From  udt_mm_ComReceiveMat_Detailed AS D inner join ( select Key_ID,WF_Config_ID from udt_mm_WFCurrent where PU_ID between 1007 and 1009) AS T ON D.GID=T.Key_ID ");
                strSql.Append("where 1=1 and T.WF_Config_ID IN( select ID from udt_mm_WFConfigure where Menu_Id=" + PageID + ") " + strWhere + " ");
                var dt = DBFactory.Default.QuerySql(strSql.ToString()).Dataset.Tables[0];
                if (dt.Rows.Count == 0)
                    return new List<udt_mm_ComReceiveMat_Detailed>();
                else
                    return EntityBase.ToList<udt_mm_ComReceiveMat_Detailed>(DBFactory.Default.QuerySql(strSql.ToString()).Dataset.Tables[0]);
            }
     

            public udt_mm_WFCurrent QueryNowStep(string strWhere)
            {
                try
                {
                    StringBuilder strSql = new StringBuilder();
                    strSql.Append("Select ");
                    strSql.Append(" Key_ID,PU_ID,WF_Config_ID ");
                    strSql.Append(" From  udt_mm_WFCurrent ");
                    strSql.Append("where 1=1 " + strWhere);
                    var dt = DBFactory.Default.QuerySql(strSql.ToString()).Dataset.Tables[0];
                    if (dt.Rows.Count == 0)
                        return new udt_mm_WFCurrent();
                    else
                        return EntityBase.ToModel<udt_mm_WFCurrent>(dt.Rows[0]);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
     

    将List 类型转换成DataTable
       public static DataTable ToDataTable(IList list)
            {
                DataTable result = new DataTable();
                if (list.Count > 0)
                {
                    PropertyInfo[] properts = list[0].GetType().GetProperties();
                    foreach (PropertyInfo pi in properts)
                    {
                        result.Columns.Add(pi.Name, pi.PropertyType);
                    }
                    for (int i = 0; i < list.Count; i++)
                    {
                        ArrayList tempList = new ArrayList();
                        foreach (PropertyInfo pi in properts)
                        {
                            object obj = pi.GetValue(list[i], null);
                            tempList.Add(obj);
                            object[] array = tempList.ToArray();
                            result.LoadDataRow(array, true);
                        }
                    }
                }
                return result;
            }
    查看一个函数执行所需的时间
    using System.Diagnostics;
       Stopwatch watch = new Stopwatch();
                        watch.Start();
    Funcation
                        watch.Stop();
                        string time = watch.ElapsedMilliseconds.ToString();
                        MsgBox.Show(time);

    OR
         //DateTime now = DateTime.Now;
         //MessageBox.Show("初始化服务!" + (DateTime.Now - now).TotalSeconds);
                
    比较两个时间大小 
                    DateTime t1 = Convert.ToDateTime(dpBegin.SelectedDate);
                    DateTime t2 = Convert.ToDateTime(dpEnd.SelectedDate);
                    int compNum = DateTime.Compare(t1, t2);  //compNum==0时间相等
                    if (compNum > 0)
                    {
                        MsgBox.Show("开始时间不能大于结束时间");
                        return;
                    }
    Camel法则:单词中,首单词的首字母小写,其余每个单词的首字母大写,多用于变量
    Pascal法则:每个单词的首字母都大写,多用于类或着方法

    换行
    var  声明的时候必须赋值
     public string ShowStandardPrice
            {
                get
                {
                    return StandardPrice.ToString("F4"); //显示decimal类型的字段位数
                }
            }
    property.PropertyType.IsGenericType   判断当前的值是否为泛型类型
    Hi, Tomorrow!
  • 相关阅读:
    BT协议分析(1)—1.0协议
    Qt线程(2) QThread中使用WorkObject
    新浪微博的开放平台官方文档太粗略,记:仿大平台来实现
    58同城 骗子太多
    代码实现业务经验(程序员的核心能力)
    gitbash 本地文件提交为一个新的项目 到 gitlab
    Spring 核心容器 IOC
    spring AOP 理解
    java不返回某些字段,包括 null
    CentOS7安装 Redis5 单实例
  • 原文地址:https://www.cnblogs.com/aikeming/p/11985860.html
Copyright © 2011-2022 走看看