private void btn_Save2_Click(object sender, EventArgs e) { try { int[] rownumberCX = this.gv_GG.GetSelectedRows();//获取产线选中行号数组; if (rownumberCX.Count() == 0) { MessageBox.Show("未选中规格!"); return; } int count = rownumberCX.Length; int scount = 0; string str = ""; foreach (int item in rownumberCX) { Mod_TPB_LINE_SPEC mod_TPB_LINE_SPEC = new Mod_TPB_LINE_SPEC(); mod_TPB_LINE_SPEC.C_STA_ID = cbo_CX.EditValue.ToString(); mod_TPB_LINE_SPEC.C_SPEC = gv_GG.GetRowCellValue(item, "C_SPEC").ToString();//规格 mod_TPB_LINE_SPEC.C_EMP_ID = RV.UI.UserInfo.userID; mod_TPB_LINE_SPEC.D_MOD_DT = RV.UI.ServerTime.timeNow(); #region 检测是否重复添加 System.Collections.Hashtable ht = new System.Collections.Hashtable(); ht.Add("C_STA_ID", mod_TPB_LINE_SPEC.C_STA_ID); ht.Add("C_SPEC", mod_TPB_LINE_SPEC.C_SPEC); ht.Add("N_STATUS", 1); if (Common.CheckRepeat.CheckTable("TPB_LINE_SPEC", ht) > 0) { str += mod_TPB_LINE_SPEC.C_SPEC + ","; } else { bll_TPB_LINE_SPEC.Add(mod_TPB_LINE_SPEC); scount += 1; } #endregion } if (str.Length > 0) { MessageBox.Show("共" + count + "条数据,保存成功" + scount + "条," + str.Substring(0, str.Length - 1) + "已存在!"); BindGGByID(); imgcbo_cx2.EditValue = cbo_CX.EditValue; QueryGG(); } else { MessageBox.Show("共" + count + "条数据,保存成功" + scount + "条"); BindGGByID(); imgcbo_cx2.EditValue = cbo_CX.EditValue; QueryGG(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btn_Stop2_Click(object sender, EventArgs e) { try { if (DialogResult.No == MessageBox.Show("是否确认停用?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)) { return; } int selectedNum = this.gv_ZGCXGG.SelectedRowsCount; int commitNum = 0; //停用记录数量 int failtNum = 0; //停用失败数量 int[] rownumber = this.gv_ZGCXGG.GetSelectedRows(); //获取选中行号数组; foreach (int item in rownumber) { string strID = this.gv_ZGCXGG.GetRowCellValue(item, "C_ID").ToString(); Mod_TPB_LINE_SPEC model = bll_TPB_LINE_SPEC.GetModel(strID); model.N_STATUS = 0; model.C_EMP_ID = RV.UI.UserInfo.userID; model.D_MOD_DT = RV.UI.ServerTime.timeNow(); bool update = bll_TPB_LINE_SPEC.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, "停用轧钢规格产线信息");//添加操作日志 BindGGByID(); QueryGG(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_LINE_SPEC GetModel(string C_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select C_ID,C_STA_ID,C_PROD_CLASS,C_STL_GRD,C_SPEC,C_STD_CODE,N_LEVEL,C_REMARK,N_STATUS,C_EMP_ID,D_MOD_DT,D_START_DATE,D_END_DATE,C_PROD_NAME,C_PROD_KIND,C_STD_MIAN_ID,C_STA_CODE,C_STA_DESC,C_LEVEL from TPB_LINE_SPEC "); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = C_ID; Mod_TPB_LINE_SPEC model = new Mod_TPB_LINE_SPEC(); DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_LINE_SPEC model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TPB_LINE_SPEC("); strSql.Append("C_STA_ID,C_PROD_CLASS,C_STL_GRD,C_SPEC,C_STD_CODE,N_LEVEL,C_REMARK,N_STATUS,C_EMP_ID,D_MOD_DT,D_START_DATE,D_END_DATE,C_PROD_NAME,C_PROD_KIND,C_STD_MIAN_ID,C_STA_CODE,C_STA_DESC,C_LEVEL)"); strSql.Append(" values ("); strSql.Append(":C_STA_ID,:C_PROD_CLASS,:C_STL_GRD,:C_SPEC,:C_STD_CODE,:N_LEVEL,:C_REMARK,:N_STATUS,:C_EMP_ID,:D_MOD_DT,:D_START_DATE,:D_END_DATE,:C_PROD_NAME,:C_PROD_KIND,:C_STD_MIAN_ID,:C_STA_CODE,:C_STA_DESC,:C_LEVEL)"); OracleParameter[] parameters = { new OracleParameter(":C_STA_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_PROD_CLASS", OracleDbType.Varchar2, 100), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 100), new OracleParameter(":C_SPEC", OracleDbType.Varchar2, 100), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":N_LEVEL", OracleDbType.Decimal, 3), new OracleParameter(":C_REMARK", OracleDbType.Varchar2, 200), new OracleParameter(":N_STATUS", OracleDbType.Decimal, 1), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100), new OracleParameter(":D_MOD_DT", OracleDbType.Date), new OracleParameter(":D_START_DATE", OracleDbType.Date), new OracleParameter(":D_END_DATE", OracleDbType.Date), new OracleParameter(":C_PROD_NAME", OracleDbType.Varchar2, 100), new OracleParameter(":C_PROD_KIND", OracleDbType.Varchar2, 100), new OracleParameter(":C_STD_MIAN_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA_DESC", OracleDbType.Varchar2, 100), new OracleParameter(":C_LEVEL", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_STA_ID; parameters[1].Value = model.C_PROD_CLASS; parameters[2].Value = model.C_STL_GRD; parameters[3].Value = model.C_SPEC; parameters[4].Value = model.C_STD_CODE; parameters[5].Value = model.N_LEVEL; parameters[6].Value = model.C_REMARK; parameters[7].Value = model.N_STATUS; parameters[8].Value = model.C_EMP_ID; parameters[9].Value = model.D_MOD_DT; parameters[10].Value = model.D_START_DATE; parameters[11].Value = model.D_END_DATE; parameters[12].Value = model.C_PROD_NAME; parameters[13].Value = model.C_PROD_KIND; parameters[14].Value = model.C_STD_MIAN_ID; parameters[15].Value = model.C_STA_CODE; parameters[16].Value = model.C_STA_DESC; parameters[17].Value = model.C_LEVEL; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_LINE_SPEC DataRowToModel(DataRow row) { Mod_TPB_LINE_SPEC model = new Mod_TPB_LINE_SPEC(); 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_PROD_CLASS"] != null) { model.C_PROD_CLASS = row["C_PROD_CLASS"].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["C_STD_CODE"] != null) { model.C_STD_CODE = row["C_STD_CODE"].ToString(); } if (row["N_LEVEL"] != null && row["N_LEVEL"].ToString() != "") { model.N_LEVEL = decimal.Parse(row["N_LEVEL"].ToString()); } if (row["C_REMARK"] != null) { model.C_REMARK = row["C_REMARK"].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["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["C_PROD_NAME"] != null) { model.C_PROD_NAME = row["C_PROD_NAME"].ToString(); } if (row["C_PROD_KIND"] != null) { model.C_PROD_KIND = row["C_PROD_KIND"].ToString(); } if (row["C_STD_MIAN_ID"] != null) { model.C_STD_MIAN_ID = row["C_STD_MIAN_ID"].ToString(); } if (row["C_STA_CODE"] != null) { model.C_STA_CODE = row["C_STA_CODE"].ToString(); } if (row["C_STA_DESC"] != null) { model.C_STA_DESC = row["C_STA_DESC"].ToString(); } if (row["C_LEVEL"] != null) { model.C_LEVEL = row["C_LEVEL"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TPB_LINE_SPEC model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TPB_LINE_SPEC set "); strSql.Append("C_STA_ID=:C_STA_ID,"); strSql.Append("C_PROD_CLASS=:C_PROD_CLASS,"); strSql.Append("C_STL_GRD=:C_STL_GRD,"); strSql.Append("C_SPEC=:C_SPEC,"); strSql.Append("C_STD_CODE=:C_STD_CODE,"); strSql.Append("N_LEVEL=:N_LEVEL,"); strSql.Append("C_REMARK=:C_REMARK,"); strSql.Append("N_STATUS=:N_STATUS,"); strSql.Append("C_EMP_ID=:C_EMP_ID,"); strSql.Append("D_MOD_DT=:D_MOD_DT,"); strSql.Append("D_START_DATE=:D_START_DATE,"); strSql.Append("D_END_DATE=:D_END_DATE,"); strSql.Append("C_PROD_NAME=:C_PROD_NAME,"); strSql.Append("C_PROD_KIND=:C_PROD_KIND,"); strSql.Append("C_STD_MIAN_ID=:C_STD_MIAN_ID,"); strSql.Append("C_STA_CODE=:C_STA_CODE,"); strSql.Append("C_STA_DESC=:C_STA_DESC,"); strSql.Append("C_LEVEL=:C_LEVEL"); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_STA_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_PROD_CLASS", OracleDbType.Varchar2, 100), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 100), new OracleParameter(":C_SPEC", OracleDbType.Varchar2, 100), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":N_LEVEL", OracleDbType.Decimal, 3), new OracleParameter(":C_REMARK", OracleDbType.Varchar2, 200), new OracleParameter(":N_STATUS", OracleDbType.Decimal, 1), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100), new OracleParameter(":D_MOD_DT", OracleDbType.Date), new OracleParameter(":D_START_DATE", OracleDbType.Date), new OracleParameter(":D_END_DATE", OracleDbType.Date), new OracleParameter(":C_PROD_NAME", OracleDbType.Varchar2, 100), new OracleParameter(":C_PROD_KIND", OracleDbType.Varchar2, 100), new OracleParameter(":C_STD_MIAN_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA_DESC", OracleDbType.Varchar2, 100), new OracleParameter(":C_LEVEL", OracleDbType.Varchar2, 100), new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_STA_ID; parameters[1].Value = model.C_PROD_CLASS; parameters[2].Value = model.C_STL_GRD; parameters[3].Value = model.C_SPEC; parameters[4].Value = model.C_STD_CODE; parameters[5].Value = model.N_LEVEL; parameters[6].Value = model.C_REMARK; parameters[7].Value = model.N_STATUS; parameters[8].Value = model.C_EMP_ID; parameters[9].Value = model.D_MOD_DT; parameters[10].Value = model.D_START_DATE; parameters[11].Value = model.D_END_DATE; parameters[12].Value = model.C_PROD_NAME; parameters[13].Value = model.C_PROD_KIND; parameters[14].Value = model.C_STD_MIAN_ID; parameters[15].Value = model.C_STA_CODE; parameters[16].Value = model.C_STA_DESC; parameters[17].Value = model.C_LEVEL; parameters[18].Value = model.C_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TPB_LINE_SPEC model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_LINE_SPEC model) { return(dal.Add(model)); }