private void custom_orderComboBox_SelectedValueChanged(object sender, EventArgs e) { string str = this.custom_orderComboBox.Text; if (str == "") { return; } string substr = ""; string inTime = ""; //try //{ // substr = str.Substring(str.Length - 8, 6); // inTime = "20" + substr.Substring(0, 2) + "/" + substr.Substring(2, 2) + "/" + substr.Substring(4, 2); // this.order_out_dateTextBox.Text = inTime; //} //catch (Exception ex) //{ // //MessageBox.Show("订单号码时间格式错误, 设置默认值!"); // this.order_out_dateTextBox.Text = DateTime.Now.ToString("yyyy/MM/dd"); //} this.order_out_dateTextBox.Text = DateTime.Now.ToString("yyyy/MM/dd"); if (Untils.isTimeError(this.order_out_dateTextBox.Text.Trim())) { this.add.Enabled = false; } try { DateTime dt1 = DateTime.Parse(inTime); DateTime dt2 = DateTime.Now; TimeSpan ts = dt2.Subtract(dt1); if (ts.TotalDays < 0) { MessageBox.Show("请检测当前机器的时间是否正确!"); return; } this.order_receive_dateTextBox.Text = dt2.ToString("yyyy/MM/dd"); } catch (Exception ex) { //MessageBox.Show("订单号码时间格式错误, 设置默认值!"); this.order_receive_dateTextBox.Text = DateTime.Now.ToString("yyyy/MM/dd"); } doQueryAfterSelection(); }
//private string requestId = ""; // private string requestNumber = ""; //private string reqeusterStatus = ""; public FRU_OutSheetForm() { InitializeComponent(); inputerTextBox.Text = LoginForm.currentUser; this.input_dateTextBox.Text = DateTime.Now.ToString("yyyy/MM/dd"); if (Untils.isTimeError(this.input_dateTextBox.Text.Trim())) { this.add.Enabled = false; } loadInformation(); if (User.UserSelfForm.isSuperManager() == false) { this.modify.Visible = false; this.delete.Visible = false; } }
private void dataGridViewToReturn_CellClick(object sender, DataGridViewCellEventArgs e) { if (this.dataGridViewToReturn.CurrentRow == null) { return; } try { this.return_file_noTextBox.Text = generateFileNo(); this.ordernoTextBox.Text = dataGridViewToReturn.SelectedCells[0].Value.ToString(); this.custommaterialNoTextBox.Text = dataGridViewToReturn.SelectedCells[1].Value.ToString(); this.return_dateTextBox.Text = DateTime.Now.ToString("yyyy/MM/dd"); if (Untils.isTimeError(this.return_dateTextBox.Text.Trim())) { this.returnStore.Enabled = false; } this.tatTextBox.Text = dataGridViewToReturn.SelectedCells[5].Value.ToString(); //根据输入的客户料号,查询MB物料对照表找到dpk状态与mpn try { SqlConnection mConn = new SqlConnection(Constlist.ConStr); mConn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = mConn; cmd.CommandType = CommandType.Text; cmd.CommandText = "select storehouse from receiveOrder where vendor='" + vendorStr + "' and product ='" + productStr + "' and _status = 'close'"; SqlDataReader querySdr = cmd.ExecuteReader(); while (querySdr.Read()) { this.storehouseTextBox.Text = querySdr[0].ToString(); } querySdr.Close(); //列出所有可用的flexid给flexidcomboBox cmd.CommandText = "select flex_id from flexidRecord where custom_order='" + ordernoTextBox.Text + "' and custommaterialNo ='" + custommaterialNoTextBox.Text + "' and _status = ''"; querySdr = cmd.ExecuteReader(); flexidcomboBox.Items.Clear(); while (querySdr.Read()) { flexidcomboBox.Items.Add(querySdr[0].ToString()); } querySdr.Close(); cmd.CommandText = "select dpk_type, mpn, replace_custom_materialNo from MBMaterialCompare where custommaterialNo = '" + this.custommaterialNoTextBox.Text.Trim() + "'"; querySdr = cmd.ExecuteReader(); while (querySdr.Read()) { this.dpkpnTextBox.Text = querySdr[0].ToString(); this.bommpnTextBox.Text = querySdr[1].ToString(); this.replace_custom_materialNotextBox.Text = querySdr[2].ToString(); } querySdr.Close(); mConn.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void track_serial_noTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == System.Convert.ToChar(13)) { bool error = false; if (this.track_serial_noTextBox.Text.Trim() == "") { this.track_serial_noTextBox.Focus(); MessageBox.Show("追踪条码的内容为空,请检查!"); error = true; return; } try { SqlConnection mConn = new SqlConnection(Constlist.ConStr); mConn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = mConn; cmd.CommandType = CommandType.Text; //使用top 1保证选择是维修过来的最新的一个记录 cmd.CommandText = "select top 1 vendor, product,source,orderno,receivedate,mb_brief, custom_serial_no,vendor_serail_no,mpn,mb_make_date,customFault," + "mbfa1,short_cut,bgatype,BGAPN,BGA_place,bga_brief,repairer,repair_date, countNum, _status " + "from bga_wait_record_table where track_serial_no='" + this.track_serial_noTextBox.Text.Trim() + "' order by Id desc"; SqlDataReader querySdr = cmd.ExecuteReader(); string status = ""; while (querySdr.Read()) { this.vendorTextBox.Text = querySdr[0].ToString(); this.producttextBox.Text = querySdr[1].ToString(); this.sourcetextBox.Text = querySdr[2].ToString(); this.ordernotextBox.Text = querySdr[3].ToString(); this.receivedatetextBox.Text = DateTime.Parse(querySdr[4].ToString()).ToString("yyyy/MM/dd"); this.mb_brieftextBox.Text = querySdr[5].ToString(); this.custom_serial_notextBox.Text = querySdr[6].ToString(); this.vendor_serail_notextBox.Text = querySdr[7].ToString(); this.mpntextBox.Text = querySdr[8].ToString(); this.mb_make_dateTextBox.Text = DateTime.Parse(querySdr[9].ToString()).ToString("yyyy/MM/dd"); this.customFaulttextBox.Text = querySdr[10].ToString(); this.mbfa1label.Text = querySdr[11].ToString(); this.shortcutlabel.Text = querySdr[12].ToString(); this.bgatypetextBox.Text = querySdr[13].ToString(); this.BGAPNtextBox.Text = querySdr[14].ToString(); this.BGA_placetextBox.Text = querySdr[15].ToString(); this.bga_brieftextBox.Text = querySdr[16].ToString(); this.repairertextBox.Text = querySdr[17].ToString(); this.repair_datetextBox.Text = DateTime.Parse(querySdr[18].ToString()).ToString("yyyy/MM/dd"); this.countNumtextBox.Text = querySdr[19].ToString(); status = querySdr[20].ToString(); } querySdr.Close(); mConn.Close(); if (status == "" || status != "BGA不良") { this.track_serial_noTextBox.Focus(); this.track_serial_noTextBox.SelectAll(); MessageBox.Show("追踪条码的内容不在待维修记录表中或待维修记录的状态不是BGA不良,请检查!"); return; } } catch (Exception ex) { this.track_serial_noTextBox.Focus(); this.track_serial_noTextBox.SelectAll(); //MessageBox.Show("追踪条码的内容不在收货表中,请检查!"); } if (!error) { this.bgaRepair_resultcomboBox.Focus(); bgarepairertextBox.Text = LoginForm.currentUser; bgarepairDatetextBox.Text = DateTime.Now.ToString("yyyy/MM/dd"); if (Untils.isTimeError(this.repair_datetextBox.Text.Trim())) { this.add.Enabled = false; } } } }
private void custom_serial_noTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == System.Convert.ToChar(13)) { string customSerialNo = this.custom_serial_noTextBox.Text; customSerialNo = Regex.Replace(customSerialNo, "[^a-zA-Z0-9]", ""); this.custom_serial_noTextBox.Text = customSerialNo; if (customSerialNo.StartsWith("8S")) { if (customSerialNo.Length != 23) { this.custom_serial_noTextBox.Focus(); this.custom_serial_noTextBox.SelectAll(); MessageBox.Show("客户序号的长度不是23位,请检查!"); return; } } else if (customSerialNo.StartsWith("11S")) { if (customSerialNo.Length != 22) { this.custom_serial_noTextBox.Focus(); this.custom_serial_noTextBox.SelectAll(); MessageBox.Show("客户序号的长度不是22位,请检查!"); return; } } if (this.productTextBox.Text != "TBG" && this.productTextBox.Text != "DT")//在某种客户别下 客户序号包含客户料号的东西,需要主动验证 { //需要去掉前面的非0字段 string customSerial = this.custommaterialNoTextBox.Text.TrimStart('0'); if (this.custom_serial_noTextBox.Text.ToLower().Contains(customSerial.ToLower()) == false) { MessageBox.Show("在" + this.productTextBox.Text + "下客户序号没有包含客户料号"); this.custom_serial_noTextBox.Focus(); this.custom_serial_noTextBox.SelectAll(); return; } } string subData = ""; if (customSerialNo.StartsWith("8S")) { subData = customSerialNo.Substring(customSerialNo.Length - 7, 3); } else if (customSerialNo.StartsWith("11S")) { subData = customSerialNo.Substring(customSerialNo.Length - 6, 3); } else { MessageBox.Show("客户序号没有包含,没有做计算时间处理"); this.custom_serial_noTextBox.Focus(); this.custom_serial_noTextBox.SelectAll(); return; } //检查客户序号或厂商序号是否已经存在本订单编号里面了,收货表中 string vendor = ""; try { SqlConnection mConn = new SqlConnection(Constlist.ConStr); mConn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = mConn; cmd.CommandType = CommandType.Text; cmd.CommandText = "select vendor from " + this.tableName + " where custom_serial_no = '" + this.custom_serial_noTextBox.Text + "' and custom_order = '" + this.custom_orderComboBox.Text + "'"; SqlDataReader querySdr = cmd.ExecuteReader(); while (querySdr.Read()) { vendor = querySdr[0].ToString(); } querySdr.Close(); if (vendor != "") { MessageBox.Show("客户序号:" + this.custom_serial_noTextBox.Text + " 已经被使用过,请检测是否有错误!"); this.custom_serial_noTextBox.Focus(); this.custom_serial_noTextBox.SelectAll(); return; } mConn.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } string year = Untils.getTimeByChar(true, Convert.ToChar(subData.Substring(0, 1))); string mouth = Untils.getTimeByChar(false, Convert.ToChar(subData.Substring(1, 1))); string day = Untils.getTimeByChar(false, Convert.ToChar(subData.Substring(2, 1))); this.mb_make_dateTextBox.Text = year + "/" + mouth + "/" + day; try { DateTime dt1 = Convert.ToDateTime(this.mb_make_dateTextBox.Text); DateTime dt2 = Convert.ToDateTime(this.order_receive_dateTextBox.Text); string period = this.warranty_periodTextBox.Text; if (period != "") { int warranty = Int32.Parse(period.Substring(0, period.Length - 1)); dt1 = dt1.AddMonths(warranty);//生产日期加上保修期 TimeSpan ts = dt2.Subtract(dt1); int overdays = ts.Days; if (overdays >= 0) { this.guaranteeComboBox.Text = "保外"; this.guaranteeComboBox.Enabled = false; this.customResponsibilityComboBox.Text = "过保"; // this.customResponsibilityComboBox.Enabled = false; MessageBox.Show((overdays) + " 天超过, 已经过保!"); } else { this.guaranteeComboBox.Text = ""; this.guaranteeComboBox.Enabled = true; this.customResponsibilityComboBox.Text = ""; //this.customResponsibilityComboBox.Enabled = true; } } } catch (Exception ex) { MessageBox.Show("客户料号里面的日期规则不对!"); } this.vendor_serail_noTextBox.Focus(); this.vendor_serail_noTextBox.SelectAll(); } }
private void track_serial_noTextBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == System.Convert.ToChar(13)) { bool error = false; if (this.track_serial_noTextBox.Text.Trim() == "") { this.track_serial_noTextBox.Focus(); MessageBox.Show("追踪条码的内容为空,请检查!"); error = true; return; } this.track_serial_noTextBox.Text = this.track_serial_noTextBox.Text.ToUpper(); try { SqlConnection mConn = new SqlConnection(Constlist.ConStr); mConn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = mConn; cmd.CommandType = CommandType.Text; cmd.CommandText = "select Id from cidRecord where track_serial_no='" + this.track_serial_noTextBox.Text.Trim() + "'"; SqlDataReader querySdr = cmd.ExecuteReader(); string cidExist = ""; while (querySdr.Read()) { cidExist = querySdr[0].ToString(); } querySdr.Close(); if (cidExist != "") { MessageBox.Show("此序列号已经在CID中,不能走下面的流程!"); mConn.Close(); return; } cmd.CommandText = "select custommaterialNo, source_brief,custom_order,order_receive_date,custom_serial_no,vendor_serail_no, mb_make_date,custom_fault from DeliveredTable where track_serial_no='" + this.track_serial_noTextBox.Text.Trim() + "'"; querySdr = cmd.ExecuteReader(); string customMaterialNo = ""; string sourceBrief = "", customOrder = "", order_receive_date = "", custom_serial_no = "", vendor_serial_no = "", mb_make_date = "", custom_fault = ""; while (querySdr.Read()) { customMaterialNo = querySdr[0].ToString(); sourceBrief = querySdr[1].ToString(); customOrder = querySdr[2].ToString(); order_receive_date = querySdr[3].ToString(); custom_serial_no = querySdr[4].ToString(); vendor_serial_no = querySdr[5].ToString(); mb_make_date = DateTime.Parse(querySdr[6].ToString()).ToString("yyyy/MM/dd"); custom_fault = querySdr[7].ToString(); } querySdr.Close(); if (customMaterialNo != "") { string vendor = "", product = "", mb_describe = "", mb_brief = "", mpn = "", eco = ""; cmd.CommandText = "select vendor,product, mb_descripe, mb_brief,mpn,eco from MBMaterialCompare where custommaterialNo='" + customMaterialNo + "'"; querySdr = cmd.ExecuteReader(); while (querySdr.Read()) { vendor = querySdr[0].ToString(); product = querySdr[1].ToString(); mb_describe = querySdr[2].ToString(); mb_brief = querySdr[3].ToString(); mpn = querySdr[4].ToString(); eco = querySdr[5].ToString(); } querySdr.Close(); this.vendorTextBox.Text = vendor; this.producttextBox.Text = product; this.sourcetextBox.Text = sourceBrief; this.ordernotextBox.Text = customOrder; this.receivedatetextBox.Text = order_receive_date; this.mb_describetextBox.Text = mb_describe; this.mb_brieftextBox.Text = mb_brief; this.custom_serial_notextBox.Text = custom_serial_no; this.vendor_serail_notextBox.Text = vendor_serial_no; this.mpntextBox.Text = mpn; this.mb_make_dateTextBox.Text = mb_make_date; this.customFaulttextBox.Text = custom_fault; this.ECOtextBox.Text = eco; this.repair_datetextBox.Text = DateTime.Now.ToString("yyyy/MM/dd"); if (Untils.isTimeError(this.repair_datetextBox.Text.Trim())) { this.add.Enabled = false; } } else { this.track_serial_noTextBox.Focus(); this.track_serial_noTextBox.SelectAll(); MessageBox.Show("追踪条码的内容不在收货表中,请检查!"); error = true; mConn.Close(); return; } //查询bga的维修记录,如果有bga的维修记录,则取最后一条,判断状态是否是不是“BGA待换”,否则提示报错,然后把相关bga的内容填入相应内容中去 cmd.CommandText = "select top 1 bga_repair_result,bgatype,BGAPN,BGA_place,bga_brief,mbfa1 from bga_repair_record_table where track_serial_no='" + this.track_serial_noTextBox.Text.Trim() + "' order by Id desc"; querySdr = cmd.ExecuteReader(); string bga_repair_result = "", bgatype = "", BGAPN = "", BGA_place = "", bga_brief = "", mbfa1 = ""; while (querySdr.Read()) { bga_repair_result = querySdr[0].ToString(); bgatype = querySdr[1].ToString(); BGAPN = querySdr[2].ToString(); BGA_place = querySdr[3].ToString(); bga_brief = querySdr[4].ToString(); mbfa1 = querySdr[5].ToString(); } querySdr.Close(); if (bga_repair_result != "" && bga_repair_result == "BGA待换") { MessageBox.Show("BGA的状态不应该是BGA待换,BGA的维修状态还没有完成!!!"); this.vendorTextBox.Text = ""; this.producttextBox.Text = ""; this.sourcetextBox.Text = ""; this.ordernotextBox.Text = ""; this.receivedatetextBox.Text = ""; this.mb_describetextBox.Text = ""; this.mb_brieftextBox.Text = ""; this.custom_serial_notextBox.Text = ""; this.vendor_serail_notextBox.Text = ""; this.mpntextBox.Text = ""; this.mb_make_dateTextBox.Text = ""; this.customFaulttextBox.Text = ""; this.ECOtextBox.Text = ""; mConn.Close(); return; } else { this.bga_brieftextBox.Text = bga_brief; this.BGAPNtextBox.Text = BGAPN; this.BGA_placetextBox.Text = BGA_place; this.mbfa1richTextBox.Text = mbfa1; if (bgatype == "VGA") { this.VGA.Checked = true; } else if (bgatype == "CPU") { this.CPU.Checked = true; } else if (bgatype == "PCH") { this.PCH.Checked = true; } } mConn.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } this.repair_datetextBox.Text = DateTime.Now.ToString("yyyy/MM/dd"); if (!error) { } } }