/// <summary> /// 查询生产信息 /// </summary> /// <param name="datePicker1">起始时间</param> /// <param name="datePicker2">终止时间</param> /// <returns>生产信息</returns> public static DataTable SearchSubsidiaryInfo(string datePicker1, string datePicker2) { DataTable dt = ProductionSubsidiary.GetTableSchema(); string sql = DB_SQL.Sel_SubsidiaryInfo(datePicker1, datePicker2); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); int n = 0; while (objSqlReader.Read()) { n += 1; DataRow dr = dt.NewRow(); dr[0] = objSqlReader[0].ToString(); dr[1] = objSqlReader[1].ToString(); dr[2] = objSqlReader[2].ToString(); dr[3] = objSqlReader[3].ToString(); dr[4] = objSqlReader[4].ToString(); dt.Rows.Add(dr); } if (n == 0) { MessageBox.Show("没有生产数据!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(dt); }
/// <summary> /// 查询同一订单编号已上料数量 /// </summary> /// <param name="orderNum">订单编号</param> /// <returns>已上料数量</returns> public static int SearchLoadNumAllByOrderNum(string orderNum, out int orderQuantity) { int loadNumAll = 0; orderQuantity = 0; string sql = DB_SQL.Sel_LoadNumAllByOrderNum(orderNum); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); while (objSqlReader.Read()) { int.TryParse(objSqlReader[1].ToString(), out int quantity); orderQuantity = quantity; int.TryParse(objSqlReader[2].ToString(), out int loadNum); loadNumAll = loadNumAll + loadNum; } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(loadNumAll); }
/// <summary> /// 查询上料批次ID是否存在 /// </summary> /// <param name="loadBatchID">上料批次ID</param> /// <returns>true or false</returns> public static bool SearchLoadBatchID(string loadBatchID) { bool flag = false; string sql = DB_SQL.Sel_InfoByLoadBatchID(loadBatchID); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); while (objSqlReader.Read()) { flag = true; } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(flag); }
/// <summary> /// 插入新上料信息 /// </summary> /// <param name="doorInformation">门信息类</param> /// <returns>true or false</returns> public static bool InsertLoadDoorInfo(DoorInformation doorInformation) { bool flag = false; string sql = DB_SQL.In_LoadDoorInfo(doorInformation); SqlConnection conn = null; SqlCommand cmd = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); int n = cmd.ExecuteNonQuery(); if (n > 0) { flag = true; } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(flag); }
/// <summary> /// 根据订单号查询门信息 /// </summary> /// <param name="orderNum">订单号</param> /// <returns>门信息</returns> public static OrderInformation SearchOrderInfoByOrderNum(string orderNum) { OrderInformation orderInformation = null; string sql = DB_SQL.Sel_InfoByOrderNum(orderNum); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); int n = 0; while (objSqlReader.Read()) { n += 1; orderInformation = new OrderInformation { OrderNum = objSqlReader[0].ToString().Trim(), OrderQuantity = objSqlReader[1].ToString().Trim(), ProductLine = objSqlReader[2].ToString().Trim(), DoorThickness = objSqlReader[3].ToString().Trim(), DoorStructure = objSqlReader[4].ToString().Trim(), SpecificationsWide = objSqlReader[5].ToString().Trim(), SpecificationHigh = objSqlReader[6].ToString().Trim(), FacadeStyle = objSqlReader[7].ToString().Trim(), ChildDoorStyle = objSqlReader[8].ToString().Trim(), Lock = objSqlReader[9].ToString().Trim(), Overdye = objSqlReader[10].ToString().Trim(), Doorframe = objSqlReader[11].ToString().Trim(), OpenTo = objSqlReader[12].ToString().Trim(), Buckles = objSqlReader[13].ToString().Trim(), ColorCategories = objSqlReader[14].ToString().Trim(), PictureDoorSpecification = objSqlReader[15].ToString().Trim(), CustomerSpecialRequirements = objSqlReader[16].ToString().Trim() }; } if (n == 0) { MessageBox.Show("订单号" + orderNum + "不存在!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(orderInformation); }
public static UserInformation_Kp SearchUserInfo(string accountID) { UserInformation_Kp userInformation_Kp = null; string sql = DB_SQL.Sel_LoginInfo(accountID); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); int n = 0; while (objSqlReader.Read()) { n += 1; userInformation_Kp = new UserInformation_Kp() { AccountID = objSqlReader[0].ToString().Trim(), UserName = objSqlReader[1].ToString().Trim(), Password = objSqlReader[2].ToString().Trim(), Status = objSqlReader[3].ToString().Trim(), UserLevel = objSqlReader[4].ToString().Trim(), CreateUserID = objSqlReader[5].ToString().Trim(), CreateTime = objSqlReader[6].ToString().Trim(), UpdateUserID = objSqlReader[7].ToString().Trim(), UpdateUserName = objSqlReader[8].ToString().Trim(), UpdateTime = objSqlReader[9].ToString().Trim() }; } if (n == 0) { MessageBox.Show("用户名不存在!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(userInformation_Kp); }
public static DataTable searchProductInfo(string datePicker1, string datePicker2) { DataTable dt = Product.GetTableSchema(); if (datePicker1 != "" && datePicker2 != "") { string sql = DB_SQL.Sel_ProductInfo(datePicker1, datePicker2); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); int n = 0; while (objSqlReader.Read()) { n += 1; DataRow dr = dt.NewRow(); dr[0] = objSqlReader[0].ToString().Trim(); string str = objSqlReader[1].ToString().Trim(); string[] strArray = str.Split(' '); dr[1] = strArray[0]; //dr[1] = objSqlReader[1].ToString().Trim().Remove(10); dr[2] = objSqlReader[2].ToString().Trim(); dr[3] = objSqlReader[3].ToString().Trim(); dt.Rows.Add(dr); } if (n == 0) { MessageBox.Show("没有生产数据!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } } else { MessageBox.Show("请选择需要的时间!"); } return(dt); }
public static DataTable searchAlarmInfo(string alarmDatePicker1, string alarmDatePicker2, string selKeyTxt) { DataTable dt = HistoryAlarm.GetAlarmTable(); string sql = DB_SQL.Sel_AlarmInfo(alarmDatePicker1, alarmDatePicker2, selKeyTxt); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; if ((alarmDatePicker1 == "" || alarmDatePicker2 == "") && selKeyTxt == "") { MessageBox.Show("请选择正确的时间段!"); } else { try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); int n = 0; while (objSqlReader.Read()) { n += 1; DataRow dr = dt.NewRow(); dr[0] = objSqlReader[0].ToString().Trim(); dr[1] = objSqlReader[1].ToString().Trim(); switch (objSqlReader[2].ToString().Trim()) { case "0": dr[2] = "已处理"; break; case "1": dr[2] = "未处理"; break; } dt.Rows.Add(dr); } if (n == 0) { MessageBox.Show("没有报警!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } } return(dt); }
/// <summary> /// 查询生产信息详情 /// </summary> /// <param name="doorID">门ID</param> /// <param name="workSheetNumber">工单编号</param> /// <returns>详情信息</returns> public static SubsidiaryInformation SearchInfoByID(string doorID, string workSheetNumber) { SubsidiaryInformation subsidiaryInformation = null; string sql = DB_SQL.Sel_SubsidiaryInfoByID(doorID, workSheetNumber); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); int n = 0; while (objSqlReader.Read()) { subsidiaryInformation = new SubsidiaryInformation(); subsidiaryInformation.DoorID = objSqlReader[0].ToString(); subsidiaryInformation.DoorMold = objSqlReader[1].ToString(); subsidiaryInformation.OrderNum = objSqlReader[2].ToString(); subsidiaryInformation.OpenDirection = objSqlReader[3].ToString(); int.TryParse(objSqlReader[4].ToString(), out int thinPlateLength); subsidiaryInformation.ThinPlateLength = thinPlateLength; int.TryParse(objSqlReader[5].ToString(), out int thinPlateWidth); subsidiaryInformation.ThinPlateWidth = thinPlateWidth; int.TryParse(objSqlReader[6].ToString(), out int thickPlateLength); subsidiaryInformation.ThickPlateLength = thickPlateLength; int.TryParse(objSqlReader[7].ToString(), out int thickPlateWidth); subsidiaryInformation.ThickPlateWidth = thickPlateWidth; int.TryParse(objSqlReader[8].ToString(), out int thickness); subsidiaryInformation.Thickness = thickness; subsidiaryInformation.FeedingTime = objSqlReader[9].ToString(); subsidiaryInformation.LaminationPullInTime = objSqlReader[10].ToString(); subsidiaryInformation.LaminationPullOutTime = objSqlReader[11].ToString(); int.TryParse(objSqlReader[12].ToString(), out int laminationDosage); subsidiaryInformation.LaminationDosage = laminationDosage; int.TryParse(objSqlReader[13].ToString(), out int episporiumAllowance); subsidiaryInformation.EpisporiumAllowance = episporiumAllowance; int.TryParse(objSqlReader[14].ToString(), out int counterdieAllowance); subsidiaryInformation.CounterdieAllowance = counterdieAllowance; int.TryParse(objSqlReader[15].ToString(), out int cuttingLength); subsidiaryInformation.CuttingLength = cuttingLength; int.TryParse(objSqlReader[16].ToString(), out int cuttingWidth); subsidiaryInformation.CuttingWidth = cuttingWidth; subsidiaryInformation.GluingPullInTime = objSqlReader[17].ToString(); subsidiaryInformation.GluingPullOutTime = objSqlReader[18].ToString(); int.TryParse(objSqlReader[19].ToString(), out int thinPlateKeyholeX); subsidiaryInformation.ThinPlateKeyholeX = thinPlateKeyholeX; int.TryParse(objSqlReader[20].ToString(), out int thinPlateKeyholeY); subsidiaryInformation.ThinPlateKeyholeY = thinPlateKeyholeY; int.TryParse(objSqlReader[21].ToString(), out int thickPlateKeyholeX); subsidiaryInformation.ThickPlateKeyholeX = thickPlateKeyholeX; int.TryParse(objSqlReader[22].ToString(), out int thickPlateKeyholeY); subsidiaryInformation.ThickPlateKeyholeY = thickPlateKeyholeY; int.TryParse(objSqlReader[23].ToString(), out int thinPlateViewerX); subsidiaryInformation.ThinPlateViewerX = thinPlateViewerX; int.TryParse(objSqlReader[24].ToString(), out int thinPlateViewerY); subsidiaryInformation.ThinPlateViewerY = thinPlateViewerY; int.TryParse(objSqlReader[25].ToString(), out int thickPlateViewerX); subsidiaryInformation.ThickPlateViewerX = thickPlateViewerX; int.TryParse(objSqlReader[26].ToString(), out int thickPlateViewerY); subsidiaryInformation.ThickPlateViewerY = thickPlateViewerY; int.TryParse(objSqlReader[27].ToString(), out int lockWidth); subsidiaryInformation.LockWidth = lockWidth; int.TryParse(objSqlReader[28].ToString(), out int lockLength); subsidiaryInformation.LockLength = lockLength; int.TryParse(objSqlReader[29].ToString(), out int actualSerlantVolume); subsidiaryInformation.ActualSerlantVolume = actualSerlantVolume; int.TryParse(objSqlReader[30].ToString(), out int quantityGlue); subsidiaryInformation.QuantityGlue = quantityGlue; int.TryParse(objSqlReader[31].ToString(), out int gelatinizeTime); subsidiaryInformation.GelatinizeTime = gelatinizeTime; subsidiaryInformation.PerliteFillingPullInTime = objSqlReader[32].ToString(); subsidiaryInformation.PerliteFillingPullOutTime = objSqlReader[33].ToString(); int.TryParse(objSqlReader[34].ToString(), out int perliteLength); subsidiaryInformation.PerliteLength = perliteLength; int.TryParse(objSqlReader[35].ToString(), out int perliteWidth); subsidiaryInformation.PerliteWidth = perliteWidth; int.TryParse(objSqlReader[36].ToString(), out int perliteThickness); subsidiaryInformation.PerliteThickness = perliteThickness; subsidiaryInformation.PressFitPullInTime = objSqlReader[37].ToString(); subsidiaryInformation.PressFitPullOutTime = objSqlReader[38].ToString(); int.TryParse(objSqlReader[39].ToString(), out int pressFitTemperature); subsidiaryInformation.PressFitTemperature = pressFitTemperature; subsidiaryInformation.PolishedPullInTime = objSqlReader[40].ToString(); subsidiaryInformation.PolishedPullOutTime = objSqlReader[41].ToString(); subsidiaryInformation.WeldingPullInTime = objSqlReader[42].ToString(); subsidiaryInformation.WeldingPullOutTime = objSqlReader[43].ToString(); subsidiaryInformation.WeldSpacingUpDownStr = objSqlReader[44].ToString(); subsidiaryInformation.WeldSpacingHingeStr = objSqlReader[45].ToString(); subsidiaryInformation.WeldSpacingKeyholeStr = objSqlReader[46].ToString(); int.TryParse(objSqlReader[47].ToString(), out int weldNumUpDown); subsidiaryInformation.WeldNumUpDown = weldNumUpDown; int.TryParse(objSqlReader[48].ToString(), out int weldNumHinge); subsidiaryInformation.WeldNumHinge = weldNumHinge; int.TryParse(objSqlReader[49].ToString(), out int weldNumKeyhole); subsidiaryInformation.WeldNumKeyhole = weldNumKeyhole; int.TryParse(objSqlReader[50].ToString(), out int weldingVoltage); subsidiaryInformation.WeldingVoltage = weldingVoltage; int.TryParse(objSqlReader[51].ToString(), out int weldingElectricity); subsidiaryInformation.WeldingElectricity = weldingElectricity; int.TryParse(objSqlReader[52].ToString(), out int weldingSpendTime); subsidiaryInformation.WeldingSpendTime = weldingSpendTime; int.TryParse(objSqlReader[53].ToString(), out int wireFeedRate); subsidiaryInformation.WireFeedRate = wireFeedRate; subsidiaryInformation.SprayPaintPullInTime = objSqlReader[54].ToString(); subsidiaryInformation.SprayPaintPullOutTime = objSqlReader[55].ToString(); int.TryParse(objSqlReader[56].ToString(), out int sprayPaintSpendTime); subsidiaryInformation.SprayPaintSpendTime = sprayPaintSpendTime; subsidiaryInformation.VisualInspectionPullInTime = objSqlReader[57].ToString(); subsidiaryInformation.VisualInspectionPullOutTime = objSqlReader[58].ToString(); subsidiaryInformation.VisualInspectionResult = objSqlReader[59].ToString(); subsidiaryInformation.BlankingTime = objSqlReader[60].ToString(); } if (n == 0) { MessageBox.Show("该数据不存在!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(subsidiaryInformation); }
/// <summary> /// 查询检测详情 /// </summary> /// <param name="doorID">门ID</param> /// <param name="orderNum">订单编号</param> /// <returns>详情信息</returns> public static TestingResultInformation SearchInfoByID(string doorID, string orderNum) { TestingResultInformation testingResultInformation = null; string sql = DB_SQL.Sel_InfoByID(doorID, orderNum); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); while (objSqlReader.Read()) { testingResultInformation = new TestingResultInformation(); switch (objSqlReader[0].ToString()) { case "0": testingResultInformation.DoorEdgeResult0 = "NG"; testingResultInformation.DoorEdgeFailedReason0 = DetailValue(objSqlReader[1].ToString()); break; case "1": testingResultInformation.DoorEdgeResult0 = "OK"; testingResultInformation.DoorEdgeFailedReason0 = "-"; break; } switch (objSqlReader[2].ToString()) { case "0": testingResultInformation.DoorEdgeResult1 = "NG"; testingResultInformation.DoorEdgeFailedReason1 = DetailValue(objSqlReader[3].ToString()); break; case "1": testingResultInformation.DoorEdgeResult1 = "OK"; testingResultInformation.DoorEdgeFailedReason1 = "-"; break; } switch (objSqlReader[4].ToString()) { case "0": testingResultInformation.DoorEdgeResult2 = "NG"; testingResultInformation.DoorEdgeFailedReason2 = DetailValue(objSqlReader[5].ToString()); break; case "1": testingResultInformation.DoorEdgeResult2 = "OK"; testingResultInformation.DoorEdgeFailedReason2 = "-"; break; } switch (objSqlReader[6].ToString()) { case "0": testingResultInformation.DoorEdgeResult3 = "NG"; testingResultInformation.DoorEdgeFailedReason3 = DetailValue(objSqlReader[7].ToString()); break; case "1": testingResultInformation.DoorEdgeResult3 = "OK"; testingResultInformation.DoorEdgeFailedReason3 = "-"; break; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(testingResultInformation); }
/// <summary> /// 查询NG个数 /// </summary> /// <param name="time">时间</param> /// <param name="num">NG原因</param> /// <param name="NGno">NG边</param> /// <returns>NG个数</returns> public static int SearchNGCountNum(string time, int num, string NGno) { int NGCount = 0; string failedReason = ""; switch (num) { case 0: failedReason = "1"; break; case 1: failedReason = "2"; break; case 2: failedReason = "4"; break; case 3: failedReason = "8"; break; case 4: failedReason = "16"; break; case 5: failedReason = "32"; break; case 6: failedReason = "64"; break; case 7: failedReason = "128"; break; } string sql = DB_SQL.Sel_NGCountNum(time, failedReason, NGno); SqlConnection conn = null; SqlCommand cmd = null; SqlDataReader objSqlReader = null; try { using (conn = new SqlConnection(DB_SQL.conStr)) { using (cmd = new SqlCommand(sql, conn)) { conn.Open(); objSqlReader = cmd.ExecuteReader(); while (objSqlReader.Read()) { NGCount = int.Parse(objSqlReader[0].ToString()); } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString() + "打开数据库失败!"); } finally { if (objSqlReader != null) { objSqlReader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); conn.Dispose(); } } return(NGCount); }