/// <summary> /// /// </summary> /// <param name="appo"></param> public static void AddPlanPrint(AsmPlanPrintObject appo) { using (IDbConnection conn = ClsCommon.OpenConnection()) //这里访问的是Sqlite数据文件,这里OpenConnection即上边获取连接数据库对象方法 { var result = conn.Insert(appo); } }
public static void AddPlanPrint(AsmPlanPrintObject appo) { AsmPlanPrint_DAL.AddPlanPrint(appo); }
/// <summary> /// 构建SN并存储 /// </summary> /// <param name="list_SN"></param> /// <param name="weekofyear"></param> /// <param name="lineid"></param> /// <param name="product_name"></param> /// <returns></returns> public bool CreateBarcodeBysomething(List <string> list_SN, DateTime numofdate, AsmPlanObject apo) { try { string month_day = ""; int str_month = Convert.ToInt32(numofdate.ToString("MM")); int str_day = Convert.ToInt32(numofdate.ToString("dd")); string month = ""; string day = ""; for (int i = 1; i < 32; i++) { if (str_month == i) { month = dic_month[i]; } if (str_day == i) { day = dic_month[i]; } } bool x = true; PrintManager pm = new PrintManager(); if (list_SN.Count != 0) { List <string> list_barcode = new List <string>(); List <int> list_lastnumoffive = new List <int>(); ///截取后五位 for (int i = 0; i < list_SN.Count; i++) { // list_lastnumoffive.Add(list_SN[i].ToString().IndexOf(list_SN[i].ToString(), 18, list_SN[i].ToString().Length)); int a = list_SN[i].ToString().Length; list_lastnumoffive.Add(Convert.ToInt32(list_SN[i].ToString().Substring(a - 7, 7))); } ///比较得出最大值 int max = list_lastnumoffive[0]; int max_keep = 0; for (int i = 0; i < list_lastnumoffive.Count; i++) { if (list_lastnumoffive[i] > max) { max = list_lastnumoffive[i]; max_keep = list_lastnumoffive[i]; } } DateTime dt = DateTime.Now; int year = Convert.ToInt32(dt.ToString("yyyy")); string str_year = ""; for (int i = 2017; i < 2051; i++) { if (i == year) { str_year = dic_year[i]; } } //int a = (dt.Year % 100) - 20; for (int i = 0; i < apo.NUMBER; i++) { max += 1; list_barcode.Add("0" + apo.LINE_ID + apo.NAME + str_year + month + day + max.ToString("D7")); } ///存储 /// for (int i = 0; i < list_barcode.Count; i++) { AsmPlanPrintObject appo = new AsmPlanPrintObject(); appo.DT = DateTime.Now; appo.SN = list_barcode[i].ToString(); rTB_Barcode.AppendText(appo.SN + "\r"); appo.PLAN_ID = apo.ID; appo.LINE_ID = Convert.ToInt32(apo.LINE_ID); appo.PRODUCTION_ID = Convert.ToInt32(apo.PRODUCTION_ID); appo.SERIAL_NO = max_keep + i; appo.PRINT_FLAG = "0"; AsmPlanPrint_BLL.AddPlanPrint(appo); } } else { List <string> list_barcode = new List <string>(); int numOfSN = Convert.ToInt32(apo.NUMBER); DateTime dtt = DateTime.Now; int year = Convert.ToInt32(dtt.ToString("yyyy")); string str_year = ""; for (int i = 2017; i < 2051; i++) { if (i == year) { str_year = dic_year[i]; } } for (int i = 1; i < numOfSN + 1; i++) { DateTime dt = DateTime.Now; string item = "0" + apo.LINE_ID + apo.NAME + str_year + month + day + i.ToString("D7"); list_barcode.Add(item); rTB_Barcode.AppendText(item.Trim() + "\r"); } ///存储 /// for (int i = 0; i < list_barcode.Count; i++) { AsmPlanPrintObject appo = new AsmPlanPrintObject(); appo.DT = DateTime.Now; appo.SN = list_barcode[i].ToString(); appo.PLAN_ID = apo.ID; appo.LINE_ID = Convert.ToInt32(apo.LINE_ID); appo.PRODUCTION_ID = Convert.ToInt32(apo.PRODUCTION_ID); appo.SERIAL_NO = i + 1; appo.PRINT_FLAG = "0"; AsmPlanPrint_BLL.AddPlanPrint(appo); } } return(x); } catch (Exception e) { MessageBox.Show(e.Message); return(false); } }