小操作

string sqlCmd = string.Format("select COUNT(distinCt(BARCODE)) from [dbo].[SendAcerData] where INV_NO='{0}'", dtInv.Rows[i][0].ToString());
                        dtt = SqlHelper.Query(sqlCmd);
字符串的格式化

Split拆分后的是一个数组

判断字符串为空

string.IsNullOrEmpty(XXX)

快速生成Get Set属性

prop 按两下Tab

选中一列的值

列如

string a;

string b;

选中string 加入ALT便可选中 方便修改。

增加天数和时间格式转换

将String日期转成DateTime再转成String

string strSftDate=“20191016”;
DateTime date=DateTime.ParseExact(strSftDate,"yyyyMMdd",System.Globalization.CultureInfo.CurrentCulture);
strSftDate = date.AddDays(1).ToString("yyyyMMdd");
//完成天数增加并且返回sting 因为DateTime格式时分秒去不掉
View Code

 C# winform 定时器控件(看CSDN 作者una_ting的博客)

timer_MainForm.Enable = true;

timer_MainForm.Interval = 500;  //定时器时间间隔

timer_MainForm.Start();   //定时器开始工作

设置定时器属性

定时实现的行为可在Tick事件中实现。

  private void timer_MainForm_Tick(object sender, EventArgs e)
 {

     //具体实现的方法

     //

}
View Code

子控件事件冲突,无法实现Mouse事件,最后只能采取坐标的方法。

DataGirdView中checkbox是否选中代码,Value不行选用EditedFormattedValue

if ((bool)grdData.Rows[i].Cells["Select"].EditedFormattedValue==false )
{

}

 字符串四舍五入 取小数点后1位

string WaitMinute;

Convert.ToDouble(WaitMinute).ToString("0.0");//几个0取几位

 字符串不四舍五入 取小数点后1位

string WaitMinute;
double m3 = Math.Truncate((Convert.ToDouble(WaitMinute)) * 10) / 10;

HttpGet无参调用,主要使用httpclient的去调用。也可以看看RestSharp包
        public static string HttpGet(string url, string body = "")
        {
            var httpClient = new HttpClient();
            var response = httpClient.GetAsync(new Uri(url)).Result;
            var data = response.Content.ReadAsStringAsync().Result;//接口调用成功获取的数据
            return data;
        }

 

posted @ 2019-10-29 09:38  最爱吃汤圆27  阅读(132)  评论(0编辑  收藏  举报