//选择物料 private void button3_Click(object sender, EventArgs e) { //测试 T_JB_Materiel mo = mbll.getMaterielById("001"); SelectKnifeUse(mo); }
private bool CheckBarcode(string ids, ref string mes) { if (ids.Length < 1) { mes = "码为空!"; return(false); } else { try { string[] arr = ids.Split(new char[] { ',' }); for (int i = 0; i < arr.Length; i++) { T_JB_Materiel mo = mbll.getMaterielById(arr[i]); if (mo == null) { mes = "码无法解析!"; return(false); } } } catch { mes = "码无法解析!"; return(false); } } return(true); }
private void addRowMult(DataTable dtBak, T_JB_Materiel mo) { for (int j = 0; j < dtBak.Rows.Count; j++) { DataRow dr = dt.NewRow(); dr[0] = dtBak.Rows[j][0]; dr[1] = mo.C_name; dr[2] = mo.C_standerd; dr[3] = dtBak.Rows[j][3]; dr[4] = dtBak.Rows[j][4]; dr[5] = dtpIndate.Value.ToString("yyyy-MM-dd"); dr[6] = dtBak.Rows[j][6]; dr[7] = dtBak.Rows[j][7]; dr[8] = dtBak.Rows[j][8]; bool flag = false; for (int i = 0; i < dt.Rows.Count; i++) { string m = Convert.ToString(dt.Rows[i][0]); string p = Convert.ToString(dt.Rows[i][4]); if (txtId.Text.Equals(m) && txtInPlace.Text.Trim().Equals(p)) { flag = true; int old = Convert.ToInt32(dt.Rows[i][3]); int total = old + Convert.ToInt32(txtCount.Text.Trim()); dt.Rows[i][3] = total.ToString(); break; } } if (flag == false) { dt.Rows.InsertAt(dr, 0); } } }
/// <summary> /// 显示model /// </summary> /// <param name="materiel"></param> void ModelToUI(T_JB_Materiel materiel) { this.txtId.Text = materiel.C_id; this.txtMaterielName.Text = materiel.C_name; this.cmbType.SelectedValue = materiel.C_type; this.txtStand.Text = materiel.C_standerd; this.txtThick.Text = materiel.I_thick.ToString(); this.txtLength.Text = materiel.I_length.ToString(); this.txtWidth.Text = materiel.I_width.ToString(); this.cmbArea.SelectedValue = materiel.C_area; if (materiel.I_finish == 1) { this.checkBox1.Checked = true; } else { this.checkBox1.Checked = false; } this.txtMeno.Text = materiel.C_memo; this.textBox1.Text = materiel.C_piccode; this.textBox2.Text = materiel.I_layOutCount.ToString(); this.textBox3.Text = materiel.C_surface; this.textBox4.Text = materiel.C_Science; this.textBox5.Text = materiel.Dec_area.ToString(); this.textBox7.Text = materiel.Dec_weight.ToString(); this.textBox6.Text = materiel.Dec_production.ToString(); if (materiel.I_buy == 1) { this.checkBox2.Checked = true; } else { this.checkBox2.Checked = false; } }
private void btnLogin_Click(object sender, EventArgs e) { try { if (checkInput()) { #region 增加 if (bll.isExit(txtName.Text.Trim(), cmbType.SelectedValue.ToString())) { MessageBox.Show("物料名称重复!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); lblName.Visible = true; } else { lblName.Visible = false; T_JB_Materiel temp = new T_JB_Materiel(); temp.C_id = txtId.Text.Trim(); temp.C_name = txtName.Text.Trim(); temp.C_type = cmbType.SelectedValue.ToString(); temp.C_standerd = txtStandard.Text.Trim(); temp.I_length = string.Empty.Equals(txtLT.Text.Trim()) ? 0 : Convert.ToDecimal(txtLT.Text.Trim()); temp.I_width = string.Empty.Equals(txtWT.Text.Trim()) ? 0 : Convert.ToDecimal(txtWT.Text.Trim()); temp.I_thick = string.Empty.Equals(txtMT.Text.Trim()) ? 0 : Convert.ToDecimal(txtMT.Text.Trim()); temp.C_area = cmbArea.SelectedValue.ToString(); temp.C_memo = txtMeno.Text.Trim(); temp.Dec_dimension1 = string.Empty.Equals(txtDim1.Text.Trim()) ? 0 : Convert.ToDecimal(txtDim1.Text.Trim()); temp.Dec_dimension2 = string.Empty.Equals(txtDim2.Text.Trim()) ? 0 : Convert.ToDecimal(txtDim2.Text.Trim()); temp.Dec_dimension3 = string.Empty.Equals(txtDim3.Text.Trim()) ? 0 : Convert.ToDecimal(txtDim3.Text.Trim()); temp.Dec_angle = string.Empty.Equals(txtAngle.Text.Trim()) ? 0 : Convert.ToDecimal(txtAngle.Text.Trim()); temp.C_regrinding_length = txtRL.Text.Trim(); if (bll.save(temp, Global.longid)) { MessageBox.Show("物料保存成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); Log.saveLog("添加物料成功!Id:" + txtId.Text); reset(); } else { MessageBox.Show("物料保存失败!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } #endregion } } catch (Exception) { MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void setMateriel(string name, string id, string standard) { try { materielNow = mbll.getMaterielById(id); ModelToUI(materielNow); } catch (Exception) { MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void setMaterielAndPlace(string mname, string mid, string standard, string pid, string tray, int count, string typeName) { try { materielNow = mbll.getMaterielById(mid); } catch (Exception) { MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); } ModelToUI(materielNow); }
private void ModMateriel_Load(object sender, EventArgs e) { this.Left = (Global.baseWidth) / 2; this.Top = Global.baseHeight / 4; #region 初始化 物料类别 DataTable dt = tbll.GetList(null, null, null, 1); DataView dataView = dt.DefaultView; dataView.Sort = "C_ID asc"; cmbType.DataSource = dataView.ToTable(); cmbType.DisplayMember = "C_NAME"; cmbType.ValueMember = "C_ID"; cmbType.SelectedValue = mTypeId; #endregion #region 初始化 货区 DataTable dtt = abll.GetList(null); DataView dataViewt = dtt.DefaultView; dataViewt.Sort = "C_ID asc"; cmbArea.DataSource = dataViewt.ToTable(); cmbArea.DisplayMember = "C_NAME"; cmbArea.ValueMember = "C_ID"; #endregion txtId.ReadOnly = true; materiel = bll.getMaterielById(id); if (materiel == null) { MessageBox.Show("获取物料信息失败!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } else { this.txtId.Text = materiel.C_id; this.txtName.Text = materiel.C_name; this.cmbType.SelectedValue = materiel.C_type; this.txtStandard.Text = materiel.C_standerd; this.txtMT.Text = materiel.I_thick.ToString(); this.txtLT.Text = materiel.I_length.ToString(); this.txtWT.Text = materiel.I_width.ToString(); this.cmbArea.SelectedValue = materiel.C_area; this.txtMeno.Text = materiel.C_memo; this.txtDim1.Text = materiel.Dec_dimension1.ToString(); this.txtDim2.Text = materiel.Dec_dimension2.ToString(); this.txtDim3.Text = materiel.Dec_dimension3.ToString(); this.txtAngle.Text = materiel.Dec_angle.ToString(); this.txtRL.Text = materiel.C_regrinding_length; } }
private void txtId_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { T_JB_Materiel mo = Utility.AnalyzeBarcodeMateriel(inOutType); if (mo != null) { SelectKnifeUse(mo); } else { MessageBox.Show("无法解析!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// 选择刀具 /// </summary> /// <param name="mo"></param> private void SelectKnifeUse(T_JB_Materiel mo) { dtBak = dt.Clone(); SelectKnifeUseForm select = new SelectKnifeUseForm(mo.C_id, dt, dtBak); select.ShowDialog(); if (dtBak.Rows.Count > 0) { //addRowMult(dtBak); ModelToUI(mo); txtInPlace.Text = dtBak.Rows[0][4].ToString(); txtMachine.Text = dtBak.Rows[0][7].ToString(); } }
/// <summary> /// 显示model /// </summary> /// <param name="materiel"></param> void ModelToUI(T_JB_Materiel materiel) { this.txtId.Text = materiel.C_id; this.txtMaterielName.Text = materiel.C_name; this.cmbType.SelectedValue = materiel.C_type; this.txtStand.Text = materiel.C_standerd; this.txtMT.Text = materiel.I_thick.ToString(); this.txtLT.Text = materiel.I_length.ToString(); this.txtWT.Text = materiel.I_width.ToString(); this.cmbArea.SelectedValue = materiel.C_area; this.txtMeno.Text = materiel.C_memo; this.txtDim1.Text = materiel.Dec_dimension1.ToString(); this.txtDim2.Text = materiel.Dec_dimension2.ToString(); this.txtDim3.Text = materiel.Dec_dimension3.ToString(); this.txtAngle.Text = materiel.Dec_angle.ToString(); this.txtRL.Text = materiel.C_regrinding_length; }
private void txtId_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { #region 测试 //DataTable dtBak = dt.Clone(); //SelectMaterielOutNumForm select1 = new SelectMaterielOutNumForm(this, dt, dtBak, "001001"); //select1.ShowDialog(); //addRowMult(dtBak,mbll.getMaterielById("001001")); #endregion T_JB_Materiel mo = Utility.AnalyzeBarcodeMateriel(inOutType); if (mo != null) { #region 无论多少,都要弹出框 //DataTable st = stockBll.getStocksList(null, null, null, null, Global.longid, mo.C_id); //if (st.Rows.Count == 1) //{//只有一个货位有该零件 // //ModelToUI(mo); // //txtCount.Text = Convert.ToInt32(st.Rows[0][5]).ToString(); // //txtInPlace.Text = st.Rows[0][4].ToString(); //} //else //{//多个货位,窗体选择 //} #endregion DataTable dtBak = dt.Clone(); SelectMaterielOutNumForm select = new SelectMaterielOutNumForm(this, dt, dtBak, mo.C_id); select.ShowDialog(); addRowMult(dtBak, mo); } else { MessageBox.Show("无法解析!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void txtId_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { T_JB_Materiel mo = Utility.AnalyzeBarcodeMateriel(inOutType); if (mo != null) { ModelToUI(mo); if (txtInPlace.Text.Trim().Length > 0) {//无货位自动分配 string place = pbll.GetAutoPlace(mo.C_area); } } else { MessageBox.Show("无法解析!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public void setMaterielAndPlace(string mname, string mid, string standard, string pid, string tray, int count, string typeName) { this.txtMaterielName.Text = mname; this.txtInPlace.Text = pid; this.txtCount.Text = count.ToString(); this.lblMax.Text = count.ToString(); this.lblTypeName.Text = typeName; //库存编号 this.lblStockId.Text = tray; try { materielNow = mbll.getMaterielById(mid); } catch (Exception) { MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); } ModelToUI(materielNow); }
private void btnLogin_Click(object sender, EventArgs e) { try { if (checkInput()) { if (bll.isExit(txtName.Text.Trim(), cmbType.SelectedValue.ToString(), txtId.Text.Trim())) { MessageBox.Show("物料名称已经存在!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); lblName.Visible = true; } else { lblName.Visible = false; T_JB_Materiel temp = new T_JB_Materiel(); temp.C_id = txtId.Text; temp.C_name = txtName.Text.Trim(); temp.C_type = cmbType.SelectedValue.ToString(); temp.I_single = 0; temp.C_standerd = txtStandard.Text.Trim(); temp.I_length = string.Empty.Equals(txtLength.Text.Trim()) ? 0 : Convert.ToDecimal(txtLength.Text.Trim()); temp.I_width = string.Empty.Equals(txtWidth.Text.Trim()) ? 0 : Convert.ToDecimal(txtWidth.Text.Trim()); temp.I_thick = string.Empty.Equals(txtThick.Text.Trim()) ? 0 : Convert.ToDecimal(txtThick.Text.Trim()); temp.C_area = cmbArea.SelectedValue.ToString(); temp.I_finish = 0; if (this.checkBox1.Checked) { temp.I_finish = 1; } temp.C_memo = txtMeno.Text.Trim(); temp.C_piccode = this.textBox1.Text.Trim(); temp.I_layOutCount = string.Empty.Equals(textBox2.Text.Trim()) ? 0 : Convert.ToInt32(textBox2.Text.Trim()); temp.C_surface = this.textBox3.Text.Trim(); temp.C_Science = this.textBox4.Text.Trim(); temp.Dec_area = string.Empty.Equals(textBox5.Text.Trim()) ? 0 : Convert.ToDecimal(textBox5.Text.Trim()); temp.Dec_weight = string.Empty.Equals(textBox7.Text.Trim()) ? 0 : Convert.ToDecimal(textBox7.Text.Trim()); temp.I_buy = 0; if (this.checkBox2.Checked) { temp.I_buy = 1; } temp.Dec_production = string.Empty.Equals(textBox6.Text.Trim()) ? 0 : Convert.ToDecimal(textBox6.Text.Trim()); if (bll.update(temp)) { MessageBox.Show("物料信息更改成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); Log.saveLog("修改物料成功!Id:" + txtId.Text); this.Close(); } else { MessageBox.Show("物料信息更改失败!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception) { MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 保存物料信息 /// </summary> /// <param name="user">物料信息</param> /// <returns></returns> public bool update(T_JB_Materiel materiel) { try { int count = 0; string sql = " UPDATE [T_JB_MATERIEL]SET [C_TYPE]=@C_TYPE, [C_NAME]=@C_NAME, [I_SINGLE]=@I_SINGLE, [C_STANDARD]=@C_STANDARD, [I_LENGTH]=@I_LENGTH, " + " [I_WIDTH]=@I_WIDTH, [I_THICK]=@I_THICK, [C_AREA]=@C_AREA, [I_FINISH]=@I_FINISH, [C_MEMO]=@C_MEMO, " + " [C_PICCODE]=@C_PICCODE, [I_LAYOUTCOUNT]=@I_LAYOUTCOUNT, [C_SURFACE]=@C_SURFACE, [C_SCIENCE]=@C_SCIENCE, " + " [DEC_AREA]=@DEC_AREA, [DEC_WEIGHT]=@DEC_WEIGHT, [I_BUY]=@I_BUY, [DEC_production]=@DEC_production, " + " [DEC_ANGLE]=@DEC_ANGLE, [DEC_DIMENSION1]=@DEC_DIMENSION1, [DEC_DIMENSION2]=@DEC_DIMENSION2, [DEC_DIMENSION3]=@DEC_DIMENSION3, [C_REGRINDING_LENGTH]=@C_REGRINDING_LENGTH WHERE [C_ID]=@C_ID "; Hashtable table = new Hashtable(); table.Add("C_ID", materiel.C_id); table.Add("C_TYPE", materiel.C_type); table.Add("C_NAME", materiel.C_name); table.Add("I_SINGLE", materiel.I_single); if (materiel.C_standerd == null || string.Empty.Equals(materiel.C_standerd.Trim())) { table.Add("C_STANDARD", DBNull.Value); } else { table.Add("C_STANDARD", materiel.C_standerd); } table.Add("I_LENGTH", materiel.I_length); table.Add("I_WIDTH", materiel.I_width); table.Add("I_THICK", materiel.I_thick); table.Add("C_AREA", materiel.C_area); table.Add("I_FINISH", materiel.I_finish); table.Add("C_MEMO", materiel.C_memo); table.Add("C_PICCODE", materiel.C_piccode == null ? string.Empty : materiel.C_piccode); table.Add("I_LAYOUTCOUNT", materiel.I_layOutCount); table.Add("C_SURFACE", materiel.C_surface == null ? string.Empty : materiel.C_surface); table.Add("C_SCIENCE", materiel.C_Science == null ? string.Empty : materiel.C_Science); table.Add("DEC_AREA", materiel.Dec_area); table.Add("DEC_WEIGHT", materiel.Dec_weight); table.Add("I_BUY", materiel.I_buy); table.Add("DEC_production", materiel.Dec_production); table.Add("DEC_ANGLE", materiel.Dec_angle); table.Add("DEC_DIMENSION1", materiel.Dec_dimension1); table.Add("DEC_DIMENSION2", materiel.Dec_dimension2); table.Add("DEC_DIMENSION3", materiel.Dec_dimension3); table.Add("C_REGRINDING_LENGTH", materiel.C_regrinding_length == null ? string.Empty : materiel.C_regrinding_length); DbParameter[] parms = dbHelper.getParams(table); count = dbHelper.ExecuteCommand(sql, parms); if (count > 0) { return(true); } else { return(false); } } catch (Exception ex) { Log.write(ex.Message + "\r\n" + ex.StackTrace); throw ex; } finally { dbHelper.getConnection().Close(); } }
/// <summary> /// 保存物料信息 /// </summary> /// <param name="user">物料信息</param> /// <returns></returns> public bool update(T_JB_Materiel materiel) { return(dal.update(materiel)); }
/// <summary> /// 保存物料信息 /// </summary> /// <param name="user">物料信息</param> /// <returns></returns> public bool save(T_JB_Materiel materiel, string userid) { return(dal.save(materiel, userid)); }
/// <summary> /// 验证输入 /// </summary> /// <returns></returns> private bool checkInput() { bool flag = true; if (Convert.ToDateTime(dtpIndate.Value.ToShortDateString()) > Convert.ToDateTime(DateTime.Now.ToShortDateString())) { MessageBox.Show("入库日期不能大于当前日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); flag = false; } if (flag) { if (txtInPlace.Text == null || string.Empty.Equals(txtInPlace.Text)) { flag = false; this.lblTypeName.Visible = true; } else { this.lblTypeName.Visible = false; if (bll.isPlaceInuse(txtInPlace.Text.Trim())) { this.lblTypeName.Visible = true; flag = false; } else { this.lblTypeName.Visible = false; } } } if (flag) { if (txtMaterielName.Text == null || string.Empty.Equals(txtMaterielName.Text)) { flag = false; this.lblMaterielName.Visible = true; } else { this.lblMaterielName.Visible = false; try { T_JB_Materiel materiel = mbll.getMaterielById(txtId.Text); if (materiel == null) {//当前刀具不存在,增加 if (mbll.save(materielNow, Global.longid)) { Log.saveLog("自动保存刀具成功!id:" + materielNow.C_id); } else { MessageBox.Show("自动保存刀具失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.lblMaterielName.Visible = true; flag = false; } } else {//存在,更新 this.lblMaterielName.Visible = false; //mbll.update(materielNow); } } catch (Exception) { MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } return(flag); }
/// <summary> /// 保存物料信息 /// </summary> /// <param name="user">物料信息</param> /// <returns></returns> public bool save(T_JB_Materiel materiel, string userid) { int result = 0; DbConnection conn = dbHelper.getConnection(); try { conn.Open(); } catch (Exception ex) { Log.write(ex.Message + "\r\n" + ex.StackTrace); conn.Close(); throw ex; } DbTransaction tran = conn.BeginTransaction(); DbCommand com = conn.CreateCommand(); string sql = string.Empty; try { com.Transaction = tran; sql = "INSERT INTO [T_JB_MATERIEL]([C_ID],[C_TYPE], [C_NAME], [I_SINGLE], [DEC_PRICE], [C_STANDARD], " + " [I_LENGTH], [I_WIDTH] ,[I_THICK],[C_AREA],[I_FINISH],[C_MEMO]," + " [C_PICCODE], [I_LAYOUTCOUNT], [C_SURFACE], [C_SCIENCE], [DEC_AREA], [DEC_WEIGHT], [I_BUY], [DEC_production], " + " [DEC_ANGLE], [DEC_DIMENSION1], [DEC_DIMENSION2], [DEC_DIMENSION3], [C_REGRINDING_LENGTH]) " + " VALUES(@C_ID,@C_TYPE,@C_NAME,@I_SINGLE,0,@C_STANDARD, @I_LENGTH,@I_WIDTH ,@I_THICK,@C_AREA,@I_FINISH,@C_MEMO, " + " @C_PICCODE, @I_LAYOUTCOUNT, @C_SURFACE, @C_SCIENCE, @DEC_AREA, @DEC_WEIGHT, @I_BUY, @DEC_production," + " @DEC_ANGLE, @DEC_DIMENSION1, @DEC_DIMENSION2, @DEC_DIMENSION3, @C_REGRINDING_LENGTH)"; com.CommandText = sql; Hashtable table = new Hashtable(); table.Add("C_ID", materiel.C_id); table.Add("C_TYPE", materiel.C_type); table.Add("C_NAME", materiel.C_name); table.Add("I_SINGLE", materiel.I_single); if (materiel.C_standerd == null || string.Empty.Equals(materiel.C_standerd.Trim())) { table.Add("C_STANDARD", DBNull.Value); } else { table.Add("C_STANDARD", materiel.C_standerd); } table.Add("I_LENGTH", materiel.I_length); table.Add("I_WIDTH", materiel.I_width); table.Add("I_THICK", materiel.I_thick); table.Add("C_AREA", materiel.C_area); table.Add("I_FINISH", materiel.I_finish); table.Add("C_MEMO", materiel.C_memo); table.Add("C_PICCODE", materiel.C_piccode == null ? string.Empty : materiel.C_piccode); table.Add("I_LAYOUTCOUNT", materiel.I_layOutCount); table.Add("C_SURFACE", materiel.C_surface == null ? string.Empty : materiel.C_surface); table.Add("C_SCIENCE", materiel.C_Science == null ? string.Empty : materiel.C_Science); table.Add("DEC_AREA", materiel.Dec_area); table.Add("DEC_WEIGHT", materiel.Dec_weight); table.Add("I_BUY", materiel.I_buy); table.Add("DEC_production", materiel.Dec_production); table.Add("DEC_ANGLE", materiel.Dec_angle); table.Add("DEC_DIMENSION1", materiel.Dec_dimension1); table.Add("DEC_DIMENSION2", materiel.Dec_dimension2); table.Add("DEC_DIMENSION3", materiel.Dec_dimension3); table.Add("C_REGRINDING_LENGTH", materiel.C_regrinding_length == null ? string.Empty : materiel.C_regrinding_length); DbParameter[] parms = dbHelper.getParams(table); com.Parameters.Clear(); com.Parameters.AddRange(parms); result = com.ExecuteNonQuery(); //sql = " INSERT INTO [T_JB_MATERIEL_USER]([C_MATERIEL], [C_JIAOSE], [I_YESNO]) VALUES(@C_MATERIEL, @JIAOSE, @YESNO) "; //com.CommandText = sql; //Hashtable table2 = new Hashtable(); //table2.Add("C_MATERIEL", materiel.C_id); //table2.Add("JIAOSE", userid); //table2.Add("YESNO", 1); //DbParameter[] parms2 = dbHelper.getParams(table2); //com.Parameters.Clear(); //com.Parameters.AddRange(parms2); //result = com.ExecuteNonQuery(); tran.Commit(); if (result > 0) { return(true); } else { return(false); } } catch (Exception ex) { tran.Rollback(); conn.Close(); Log.write(ex.Message + "\r\n" + ex.StackTrace); throw ex; } finally { conn.Close(); } }
private void ModMateriel_Load(object sender, EventArgs e) { this.Left = (Global.baseWidth) / 2; this.Top = Global.baseHeight / 4; #region 初始化 物料类别 DataTable dt = tbll.GetList(null, null, null, 1); DataView dataView = dt.DefaultView; dataView.Sort = "C_ID asc"; cmbType.DataSource = dataView.ToTable(); cmbType.DisplayMember = "C_NAME"; cmbType.ValueMember = "C_ID"; cmbType.SelectedValue = mTypeId; #endregion #region 初始化 货区 DataTable dtt = abll.GetList(null); DataView dataViewt = dtt.DefaultView; dataViewt.Sort = "C_ID asc"; cmbArea.DataSource = dataViewt.ToTable(); cmbArea.DisplayMember = "C_NAME"; cmbArea.ValueMember = "C_ID"; #endregion txtId.ReadOnly = true; materiel = bll.getMaterielById(id); if (materiel == null) { MessageBox.Show("获取物料信息失败!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } else { this.txtId.Text = materiel.C_id; this.txtName.Text = materiel.C_name; this.cmbType.SelectedValue = materiel.C_type; this.txtStandard.Text = materiel.C_standerd; this.txtThick.Text = materiel.I_thick.ToString(); this.txtLength.Text = materiel.I_length.ToString(); this.txtWidth.Text = materiel.I_width.ToString(); this.cmbArea.SelectedValue = materiel.C_area; if (materiel.I_finish == 1) { this.checkBox1.Checked = true; } else { this.checkBox1.Checked = false; } this.txtMeno.Text = materiel.C_memo; this.textBox1.Text = materiel.C_piccode; this.textBox2.Text = materiel.I_layOutCount.ToString(); this.textBox3.Text = materiel.C_surface; this.textBox4.Text = materiel.C_Science; this.textBox5.Text = materiel.Dec_area.ToString(); this.textBox7.Text = materiel.Dec_weight.ToString(); this.textBox6.Text = materiel.Dec_production.ToString(); if (materiel.I_buy == 1) { this.checkBox2.Checked = true; } else { this.checkBox2.Checked = false; } } }
/// <summary> /// 获得物料的详细信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public T_JB_Materiel getMaterielById(string id) { T_JB_Materiel materiel = null; string sql = " select a.C_ID,a.C_NAME,a.C_TYPE,b.C_NAME as C_TYPENAME,a.C_STANDARD,a.C_AREA,c.C_NAME as C_AREANAME,I_FINISH, " + " case I_FINISH when 1 then '是' else '否' end as C_FINISH,I_LENGTH,I_WIDTH,I_THICK,a.C_MEMO, " + " a.C_PICCODE, a.I_LAYOUTCOUNT, a.C_SURFACE, a.C_SCIENCE, a.DEC_AREA, a.DEC_WEIGHT, a.I_BUY,DEC_production, " + " a.DEC_ANGLE, a.DEC_DIMENSION1, a.DEC_DIMENSION2,a.DEC_DIMENSION3,a.C_REGRINDING_LENGTH " + " from T_JB_MATERIEL a left join T_JB_MATERIELTYPE b on a.C_TYPE = b.C_ID left join t_jb_placeArea c on a.C_AREA = c.C_ID where a.C_ID = '" + id + "'"; try { DataTable dt = dbHelper.GetDataSet(sql); if (dt != null && dt.Rows.Count > 0) { materiel = new T_JB_Materiel(); materiel.C_id = dt.Rows[0]["C_ID"].ToString(); materiel.C_name = dt.Rows[0]["C_NAME"].ToString(); materiel.C_type = dt.Rows[0]["C_TYPE"].ToString(); materiel.C_typeName = dt.Rows[0]["C_TYPENAME"].ToString(); object temp = dt.Rows[0]["C_STANDARD"]; if (temp == null || DBNull.Value.Equals(temp)) { materiel.C_standerd = string.Empty; } else { materiel.C_standerd = dt.Rows[0]["C_STANDARD"].ToString(); } temp = dt.Rows[0]["C_AREA"]; if (temp == null || DBNull.Value.Equals(temp)) { materiel.C_area = string.Empty; } else { materiel.C_area = dt.Rows[0]["C_AREA"].ToString(); } materiel.C_areaName = dt.Rows[0]["C_AREANAME"].ToString(); materiel.I_finish = Convert.ToInt32(dt.Rows[0]["I_FINISH"]); materiel.I_thick = Convert.ToDecimal(dt.Rows[0]["I_THICK"]); // materiel.I_single = Convert.ToInt32(dt.Rows[0]["I_SINGLE"]); materiel.I_length = Convert.ToDecimal(dt.Rows[0]["I_LENGTH"]); materiel.I_width = Convert.ToDecimal(dt.Rows[0]["I_WIDTH"]); temp = dt.Rows[0]["C_MEMO"]; if (temp == null || DBNull.Value.Equals(temp)) { materiel.C_memo = string.Empty; } else { materiel.C_memo = dt.Rows[0]["C_MEMO"].ToString(); } materiel.C_piccode = dt.Rows[0]["C_PICCODE"] == null || dt.Rows[0]["C_PICCODE"].Equals(DBNull.Value) ? string.Empty : dt.Rows[0]["C_PICCODE"].ToString(); materiel.I_layOutCount = Convert.ToInt32(dt.Rows[0]["I_LAYOUTCOUNT"]); materiel.C_surface = dt.Rows[0]["C_SURFACE"] == null || dt.Rows[0]["C_SURFACE"].Equals(DBNull.Value) ? string.Empty : dt.Rows[0]["C_SURFACE"].ToString(); materiel.C_Science = dt.Rows[0]["C_SCIENCE"] == null || dt.Rows[0]["C_SCIENCE"].Equals(DBNull.Value) ? string.Empty : dt.Rows[0]["C_SCIENCE"].ToString(); materiel.Dec_area = Convert.ToDecimal(dt.Rows[0]["DEC_AREA"]); materiel.Dec_weight = Convert.ToDecimal(dt.Rows[0]["DEC_WEIGHT"]); materiel.I_buy = Convert.ToInt32(dt.Rows[0]["I_BUY"]); materiel.Dec_production = Convert.ToDecimal(dt.Rows[0]["DEC_production"]); materiel.Dec_angle = Convert.ToDecimal(dt.Rows[0]["DEC_ANGLE"]); materiel.Dec_dimension1 = Convert.ToDecimal(dt.Rows[0]["DEC_DIMENSION1"]); materiel.Dec_dimension2 = Convert.ToDecimal(dt.Rows[0]["DEC_DIMENSION2"]); materiel.Dec_dimension3 = Convert.ToDecimal(dt.Rows[0]["DEC_DIMENSION3"]); materiel.C_regrinding_length = dt.Rows[0]["C_REGRINDING_LENGTH"] == null || dt.Rows[0]["C_REGRINDING_LENGTH"].Equals(DBNull.Value) ? string.Empty : dt.Rows[0]["C_REGRINDING_LENGTH"].ToString(); } } catch (Exception ex) { Log.write(ex.Message + "\r\n" + ex.StackTrace); throw ex; } finally { dbHelper.getConnection().Close(); } return(materiel); }