/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_SLAB_CAPACITY model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TPB_SLAB_CAPACITY("); strSql.Append("C_STA_ID,C_STL_GRD,C_SPEC,N_CAPACITY,D_START_DATE,D_END_DATE,N_STATUS,C_EMP_ID,D_MOD_DT,C_STD_CODE,C_PRO_ID,C_STA_DESC,C_STA_CODE,C_PROD_NAME,C_TYPE)"); strSql.Append(" values ("); strSql.Append(":C_STA_ID,:C_STL_GRD,:C_SPEC,:N_CAPACITY,:D_START_DATE,:D_END_DATE,:N_STATUS,:C_EMP_ID,:D_MOD_DT,:C_STD_CODE,:C_PRO_ID,:C_STA_DESC,:C_STA_CODE,:C_PROD_NAME,:C_TYPE)"); OracleParameter[] parameters = { new OracleParameter(":C_STA_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 100), new OracleParameter(":C_SPEC", OracleDbType.Varchar2, 100), new OracleParameter(":N_CAPACITY", OracleDbType.Decimal, 15), new OracleParameter(":D_START_DATE", OracleDbType.Date), new OracleParameter(":D_END_DATE", OracleDbType.Date), new OracleParameter(":N_STATUS", OracleDbType.Decimal, 1), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100), new OracleParameter(":D_MOD_DT", OracleDbType.Date), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_PRO_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA_DESC", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_PROD_NAME", OracleDbType.Varchar2, 100), new OracleParameter(":C_TYPE", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_STA_ID; parameters[1].Value = model.C_STL_GRD; parameters[2].Value = model.C_SPEC; parameters[3].Value = model.N_CAPACITY; parameters[4].Value = model.D_START_DATE; parameters[5].Value = model.D_END_DATE; parameters[6].Value = model.N_STATUS; parameters[7].Value = model.C_EMP_ID; parameters[8].Value = model.D_MOD_DT; parameters[9].Value = model.C_STD_CODE; parameters[10].Value = model.C_PRO_ID; parameters[11].Value = model.C_STA_DESC; parameters[12].Value = model.C_STA_CODE; parameters[13].Value = model.C_PROD_NAME; parameters[14].Value = model.C_TYPE; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void btn_WHGPCN_Click(object sender, EventArgs e) { if (txt_JSCN.Text == "0") { MessageBox.Show("产能不能为0!"); return; } int[] rownumber = this.gv_GPJSCN.GetSelectedRows();//获取选中行号数组; int succount = 0; string str = ""; if (rownumber.Count() > 0) { foreach (var item in rownumber) { Mod_TPB_SLAB_CAPACITY mod_TPB_SLAB_CAPACITY = new Mod_TPB_SLAB_CAPACITY(); mod_TPB_SLAB_CAPACITY.C_STL_GRD = gv_GPJSCN.GetRowCellValue(item, "C_STL_GRD") == null ? null : gv_GPJSCN.GetRowCellValue(item, "C_STL_GRD").ToString(); mod_TPB_SLAB_CAPACITY.C_STD_CODE = gv_GPJSCN.GetRowCellValue(item, "C_STD_CODE") == null ? null : gv_GPJSCN.GetRowCellValue(item, "C_STD_CODE").ToString(); mod_TPB_SLAB_CAPACITY.C_TYPE = cbo_ys.EditValue.ToString(); mod_TPB_SLAB_CAPACITY.C_STA_ID = cbo_GW2.EditValue.ToString(); mod_TPB_SLAB_CAPACITY.N_CAPACITY = Convert.ToDecimal(txt_JSCN.Text); mod_TPB_SLAB_CAPACITY.C_EMP_ID = RV.UI.UserInfo.userID; #region 检测是否重复添加 System.Collections.Hashtable ht = new System.Collections.Hashtable(); ht.Add("C_STA_ID", mod_TPB_SLAB_CAPACITY.C_STA_ID); ht.Add("C_STL_GRD", mod_TPB_SLAB_CAPACITY.C_STL_GRD); ht.Add("C_STD_CODE", mod_TPB_SLAB_CAPACITY.C_STD_CODE); ht.Add("N_STATUS", 1); if (Common.CheckRepeat.CheckTable("TPB_SLAB_CAPACITY", ht) > 0) { str += mod_TPB_SLAB_CAPACITY.C_PROD_NAME + "(" + mod_TPB_SLAB_CAPACITY.C_STL_GRD + "/" + mod_TPB_SLAB_CAPACITY.C_STD_CODE + "),"; } else { bll_TPB_SLAB_CAPACITY.Add(mod_TPB_SLAB_CAPACITY); succount += 1; } #endregion } if (str.Length > 0) { MessageBox.Show("共" + rownumber.Count() + "条数据,维护成功" + succount + "条," + str.Substring(0, str.Length - 1) + "已存在!"); QueryGPCN(); } else { MessageBox.Show("维护成功!"); QueryGPCN(); } } }
private void FrmPB_GPJSCN_EDIT_Load(object sender, EventArgs e) { strMenuName = RV.UI.UserInfo.menuName; Mod_TPB_SLAB_CAPACITY mod = bll_TPB_SLAB_CAPACITY.GetModel(c_id); commonSub.ImageComboBoxEditBindGW("", cbo_GW);//绑定工位 cbo_GW.EditValue = mod.C_STA_ID; cbo_GW.Enabled = false; txt_Grd.Text = mod.C_STL_GRD; txt_Grd.Enabled = false; txt_Std.Text = mod.C_STD_CODE; txt_Std.Enabled = false; txt_JSCN.Text = mod.N_CAPACITY.ToString(); cbo_DM.EditValue = mod.C_SPEC; cbo_DM.Enabled = false; cbo_ys.EditValue = mod.C_TYPE; }
private void btn_Stop_Click(object sender, EventArgs e) { try { if (DialogResult.No == MessageBox.Show("是否确认删除选中的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)) { return; } int selectedNum = this.gv_GWJSCL.SelectedRowsCount; int commitNum = 0; //删除记录数量 int failtNum = 0; //删除失败数量 int[] rownumber = this.gv_GWJSCL.GetSelectedRows(); //获取选中行号数组; for (int i = 0; i < rownumber.Length; i++) { int selectedHandle = rownumber[i]; string strID = this.gv_GWJSCL.GetRowCellValue(selectedHandle, "C_ID").ToString(); Mod_TPB_SLAB_CAPACITY model = bll_TPB_SLAB_CAPACITY.GetModel(strID); model.N_STATUS = 0; model.C_EMP_ID = RV.UI.UserInfo.userID; model.D_MOD_DT = RV.UI.ServerTime.timeNow(); model.D_END_DATE = RV.UI.ServerTime.timeNow(); bool update = bll_TPB_SLAB_CAPACITY.Update(model); if (update) { commitNum = commitNum + 1; } else { failtNum = failtNum + 1; } } MessageBox.Show("选择" + selectedNum.ToString() + "条记录,删除" + commitNum.ToString() + "条记录!"); Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "删除钢坯机时产能");//添加操作日志 QueryMain(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_SLAB_CAPACITY GetModel(string C_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select C_ID,C_STA_ID,C_STL_GRD,C_SPEC,N_CAPACITY,D_START_DATE,D_END_DATE,N_STATUS,C_EMP_ID,D_MOD_DT,C_STD_CODE,C_PRO_ID,C_STA_DESC,C_STA_CODE,C_PROD_NAME,C_TYPE from TPB_SLAB_CAPACITY "); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = C_ID; Mod_TPB_SLAB_CAPACITY model = new Mod_TPB_SLAB_CAPACITY(); DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
private void btn_Save_Click(object sender, EventArgs e) { try { Mod_TPB_SLAB_CAPACITY mod = bll_TPB_SLAB_CAPACITY.GetModel(c_id); mod.N_CAPACITY = Convert.ToDecimal(txt_JSCN.Text); mod.C_TYPE = cbo_ys.EditValue.ToString(); mod.C_EMP_ID = RV.UI.UserInfo.UserID; mod.D_MOD_DT = RV.UI.ServerTime.timeNow(); if (mod.N_CAPACITY == 0) { MessageBox.Show("保存失败!产能不能为空"); return; } bll_TPB_SLAB_CAPACITY.Update(mod); MessageBox.Show("保存成功!"); Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "修改工位历史产能");//添加操作日志 this.DialogResult = DialogResult.Cancel; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TPB_SLAB_CAPACITY model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_SLAB_CAPACITY model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TPB_SLAB_CAPACITY model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TPB_SLAB_CAPACITY set "); strSql.Append("C_STA_ID=:C_STA_ID,"); strSql.Append("C_STL_GRD=:C_STL_GRD,"); strSql.Append("C_SPEC=:C_SPEC,"); strSql.Append("N_CAPACITY=:N_CAPACITY,"); strSql.Append("D_START_DATE=:D_START_DATE,"); strSql.Append("D_END_DATE=:D_END_DATE,"); strSql.Append("N_STATUS=:N_STATUS,"); strSql.Append("C_EMP_ID=:C_EMP_ID,"); strSql.Append("D_MOD_DT=:D_MOD_DT,"); strSql.Append("C_STD_CODE=:C_STD_CODE,"); strSql.Append("C_PRO_ID=:C_PRO_ID,"); strSql.Append("C_STA_DESC=:C_STA_DESC,"); strSql.Append("C_STA_CODE=:C_STA_CODE,"); strSql.Append("C_TYPE=:C_TYPE,"); strSql.Append("C_PROD_NAME=:C_PROD_NAME"); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_STA_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 100), new OracleParameter(":C_SPEC", OracleDbType.Varchar2, 100), new OracleParameter(":N_CAPACITY", OracleDbType.Decimal, 15), new OracleParameter(":D_START_DATE", OracleDbType.Date), new OracleParameter(":D_END_DATE", OracleDbType.Date), new OracleParameter(":N_STATUS", OracleDbType.Decimal, 1), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100), new OracleParameter(":D_MOD_DT", OracleDbType.Date), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_PRO_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA_DESC", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_TYPE", OracleDbType.Varchar2, 100), new OracleParameter(":C_PROD_NAME", OracleDbType.Varchar2, 100), new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_STA_ID; parameters[1].Value = model.C_STL_GRD; parameters[2].Value = model.C_SPEC; parameters[3].Value = model.N_CAPACITY; parameters[4].Value = model.D_START_DATE; parameters[5].Value = model.D_END_DATE; parameters[6].Value = model.N_STATUS; parameters[7].Value = model.C_EMP_ID; parameters[8].Value = model.D_MOD_DT; parameters[9].Value = model.C_STD_CODE; parameters[10].Value = model.C_PRO_ID; parameters[11].Value = model.C_STA_DESC; parameters[12].Value = model.C_STA_CODE; parameters[13].Value = model.C_TYPE; parameters[14].Value = model.C_PROD_NAME; parameters[15].Value = model.C_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_SLAB_CAPACITY DataRowToModel(DataRow row) { Mod_TPB_SLAB_CAPACITY model = new Mod_TPB_SLAB_CAPACITY(); if (row != null) { if (row["C_ID"] != null) { model.C_ID = row["C_ID"].ToString(); } if (row["C_STA_ID"] != null) { model.C_STA_ID = row["C_STA_ID"].ToString(); } if (row["C_STL_GRD"] != null) { model.C_STL_GRD = row["C_STL_GRD"].ToString(); } if (row["C_SPEC"] != null) { model.C_SPEC = row["C_SPEC"].ToString(); } if (row["N_CAPACITY"] != null && row["N_CAPACITY"].ToString() != "") { model.N_CAPACITY = decimal.Parse(row["N_CAPACITY"].ToString()); } if (row["D_START_DATE"] != null && row["D_START_DATE"].ToString() != "") { model.D_START_DATE = DateTime.Parse(row["D_START_DATE"].ToString()); } if (row["D_END_DATE"] != null && row["D_END_DATE"].ToString() != "") { model.D_END_DATE = DateTime.Parse(row["D_END_DATE"].ToString()); } if (row["N_STATUS"] != null && row["N_STATUS"].ToString() != "") { model.N_STATUS = decimal.Parse(row["N_STATUS"].ToString()); } if (row["C_EMP_ID"] != null) { model.C_EMP_ID = row["C_EMP_ID"].ToString(); } if (row["D_MOD_DT"] != null && row["D_MOD_DT"].ToString() != "") { model.D_MOD_DT = DateTime.Parse(row["D_MOD_DT"].ToString()); } if (row["C_STD_CODE"] != null) { model.C_STD_CODE = row["C_STD_CODE"].ToString(); } if (row["C_PRO_ID"] != null) { model.C_PRO_ID = row["C_PRO_ID"].ToString(); } if (row["C_STA_DESC"] != null) { model.C_STA_DESC = row["C_STA_DESC"].ToString(); } if (row["C_STA_CODE"] != null) { model.C_STA_CODE = row["C_STA_CODE"].ToString(); } if (row["C_PROD_NAME"] != null) { model.C_PROD_NAME = row["C_PROD_NAME"].ToString(); } if (row["C_TYPE"] != null) { model.C_TYPE = row["C_TYPE"].ToString(); } } return(model); }
private void btn_Save_Click(object sender, EventArgs e) { try { if (DialogResult.No == MessageBox.Show("是否确认保存信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)) { return; } if (cbo_GW.EditValue.ToString() != "") { if (cbo_DM.EditValue.ToString() != "") { if (txt_JSCN.Text.Trim() != "") { int[] rownumber = this.gv_StdMain.GetSelectedRows();//获取选中行号数组; int succount = 0; string str = ""; if (rownumber.Count() > 0) { foreach (var item in rownumber) { Mod_TPB_SLAB_CAPACITY mod_TPB_SLAB_CAPACITY = new Mod_TPB_SLAB_CAPACITY(); mod_TPB_SLAB_CAPACITY.C_PROD_NAME = gv_StdMain.GetRowCellValue(item, "C_PROD_NAME") == null ? null : gv_StdMain.GetRowCellValue(item, "C_PROD_NAME").ToString(); mod_TPB_SLAB_CAPACITY.C_STL_GRD = gv_StdMain.GetRowCellValue(item, "C_STL_GRD") == null ? null : gv_StdMain.GetRowCellValue(item, "C_STL_GRD").ToString(); mod_TPB_SLAB_CAPACITY.C_STD_CODE = gv_StdMain.GetRowCellValue(item, "C_STD_CODE") == null ? null : gv_StdMain.GetRowCellValue(item, "C_STD_CODE").ToString(); if (cbo_DM.Enabled == true) { mod_TPB_SLAB_CAPACITY.C_SPEC = cbo_DM.EditValue.ToString(); } mod_TPB_SLAB_CAPACITY.C_TYPE = cbo_ys.EditValue.ToString(); mod_TPB_SLAB_CAPACITY.C_STA_ID = cbo_GW.EditValue.ToString(); mod_TPB_SLAB_CAPACITY.N_CAPACITY = Convert.ToDecimal(txt_JSCN.Text); mod_TPB_SLAB_CAPACITY.C_EMP_ID = RV.UI.UserInfo.userID; #region 检测是否重复添加 System.Collections.Hashtable ht = new System.Collections.Hashtable(); ht.Add("C_PROD_NAME", mod_TPB_SLAB_CAPACITY.C_PROD_NAME); ht.Add("C_STA_ID", mod_TPB_SLAB_CAPACITY.C_STA_ID); ht.Add("C_SPEC", mod_TPB_SLAB_CAPACITY.C_SPEC); ht.Add("C_STL_GRD", mod_TPB_SLAB_CAPACITY.C_STL_GRD); ht.Add("C_STD_CODE", mod_TPB_SLAB_CAPACITY.C_STD_CODE); ht.Add("N_STATUS", 1); if (Common.CheckRepeat.CheckTable("TPB_SLAB_CAPACITY", ht) > 0) { str += mod_TPB_SLAB_CAPACITY.C_PROD_NAME + "(" + mod_TPB_SLAB_CAPACITY.C_STL_GRD + "/" + mod_TPB_SLAB_CAPACITY.C_STD_CODE + "),"; } else { bll_TPB_SLAB_CAPACITY.Add(mod_TPB_SLAB_CAPACITY); succount += 1; } #endregion } if (str.Length > 0) { MessageBox.Show("共" + rownumber.Count() + "条数据,保存成功" + succount + "条," + str.Substring(0, str.Length - 1) + "已存在!"); cbo_GW2.EditValue = cbo_GW.EditValue; cbo_GX2.EditValue = cbo_GX1.EditValue; QueryMain(); } else { MessageBox.Show("保存成功!"); cbo_GW2.EditValue = cbo_GW.EditValue; cbo_GX2.EditValue = cbo_GX1.EditValue; QueryMain(); } } else { MessageBox.Show("请选择钢种!"); gv_StdMain.Focus(); } } else { MessageBox.Show("请输入机时产能!"); txt_JSCN.Focus(); } } else { MessageBox.Show("请选择断面!"); cbo_DM.Focus(); } } else { MessageBox.Show("请选择工位!"); cbo_GW.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }