/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Add_Click(object sender, EventArgs e) { try { DataTable dt_sta = bllSta.Get_CN_CODE(imgcbo_CJ.EditValue.ToString()).Tables[0]; int days = DateTime.DaysInMonth(dte_Time.DateTime.Year, dte_Time.DateTime.Month); int s = 0; string str = ""; if (rbtn_isty_wh.SelectedIndex == 0) { s = 1; days = 10; str = "上旬"; } if (rbtn_isty_wh.SelectedIndex == 1) { s = 11; days = 20; str = "中旬"; } if (rbtn_isty_wh.SelectedIndex == 2) { s = 21; str = "下旬"; } for (int i = s; i <= days; i++) { for (int y = 0; y < dt_sta.Rows.Count; y++) { Mod_TPB_STA_CN mod = new Mod_TPB_STA_CN(); string a = ""; if (i < 10) { a = "0" + i.ToString(); } else { a = i.ToString(); } mod.C_DATE = dte_Time.DateTime.ToString("yyyy-MM") + "-" + a; mod.C_STA = dt_sta.Rows[y]["C_STA_DESC"].ToString(); mod.C_VALUE = ""; mod.C_MONTH = str; mod.C_EMP_ID = RV.UI.UserInfo.UserID; mod.C_REMARK = dt_sta.Rows[y]["C_PRO_ID"].ToString(); bllStaCN.Add(mod); Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "添加工序产能");//添加操作日志 } } Query(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 初始加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmPB_CNLR_Load(object sender, EventArgs e) { strMenuName = RV.UI.UserInfo.menuName; DataSet dt_sta = bllSta.Get_CN(); imgcbo_STA.Properties.Items.Clear(); foreach (DataRow item in dt_sta.Tables[0].Rows)//责任单位下拉框 { imgcbo_STA.Properties.Items.Add(item["C_STA_DESC"].ToString(), item["C_STA_DESC"], -1); } Mod_TPB_STA_CN mod = bllStaCN.GetModel(c_id); dat_Time.DateTime = Convert.ToDateTime(mod.C_DATE); txt_CN.Text = mod.C_VALUE; imgcbo_STA.Text = mod.C_STA; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TPB_STA_CN model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TPB_STA_CN set "); strSql.Append("C_DATE=:C_DATE,"); strSql.Append("C_STA=:C_STA,"); strSql.Append("C_VALUE=:C_VALUE,"); 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("C_MONTH=:C_MONTH"); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_DATE", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA", OracleDbType.Varchar2, 100), new OracleParameter(":C_VALUE", OracleDbType.Varchar2, 100), new OracleParameter(":C_REMARK", OracleDbType.Varchar2, 500), 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_MONTH", OracleDbType.Varchar2, 100), new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_DATE; parameters[1].Value = model.C_STA; parameters[2].Value = model.C_VALUE; parameters[3].Value = model.C_REMARK; parameters[4].Value = model.N_STATUS; parameters[5].Value = model.C_EMP_ID; parameters[6].Value = model.D_MOD_DT; parameters[7].Value = model.C_MONTH; parameters[8].Value = model.C_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Save_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(imgcbo_STA.Text.Trim())) { MessageBox.Show("请选择车间"); return; } if (string.IsNullOrEmpty(txt_CN.Text.Trim()) || txt_CN.Text == "0") { MessageBox.Show("请输入产能"); return; } try { Mod_TPB_STA_CN mod = bllStaCN.GetModel(c_id); mod.C_DATE = dat_Time.DateTime.ToString("yyyy-MM-dd"); mod.C_STA = imgcbo_STA.Text.Trim(); mod.C_VALUE = txt_CN.Text.Trim(); mod.C_EMP_ID = RV.UI.UserInfo.UserID; mod.D_MOD_DT = RV.UI.ServerTime.timeNow(); #region 检测是否重复添加 System.Collections.Hashtable ht = new System.Collections.Hashtable(); ht.Add("C_ID", c_id); ht.Add("C_DATE", mod.C_DATE); ht.Add("C_STA", mod.C_STA); ht.Add("N_STATUS", "1"); if (Common.CheckRepeat.CheckTable("TPB_STA_CN", ht) > 0) { MessageBox.Show("已存在,不能重复添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endregion if (bllStaCN.Update(mod)) { MessageBox.Show("保存成功!"); Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "修改工序产能");//添加操作日志 return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_STA_CN DataRowToModel(DataRow row) { Mod_TPB_STA_CN model = new Mod_TPB_STA_CN(); if (row != null) { if (row["C_ID"] != null) { model.C_ID = row["C_ID"].ToString(); } if (row["C_DATE"] != null) { model.C_DATE = row["C_DATE"].ToString(); } if (row["C_STA"] != null) { model.C_STA = row["C_STA"].ToString(); } if (row["C_VALUE"] != null) { model.C_VALUE = row["C_VALUE"].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["C_MONTH"] != null) { model.C_MONTH = row["C_MONTH"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_STA_CN model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TPB_STA_CN("); strSql.Append("C_DATE,C_STA,C_VALUE,C_REMARK,N_STATUS,C_EMP_ID,D_MOD_DT,C_MONTH)"); strSql.Append(" values ("); strSql.Append(":C_DATE,:C_STA,:C_VALUE,:C_REMARK,:N_STATUS,:C_EMP_ID,:D_MOD_DT,:C_MONTH)"); OracleParameter[] parameters = { new OracleParameter(":C_DATE", OracleDbType.Varchar2, 100), new OracleParameter(":C_STA", OracleDbType.Varchar2, 100), new OracleParameter(":C_VALUE", OracleDbType.Varchar2, 100), new OracleParameter(":C_REMARK", OracleDbType.Varchar2, 500), 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_MONTH", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_DATE; parameters[1].Value = model.C_STA; parameters[2].Value = model.C_VALUE; parameters[3].Value = model.C_REMARK; parameters[4].Value = model.N_STATUS; parameters[5].Value = model.C_EMP_ID; parameters[6].Value = model.D_MOD_DT; parameters[7].Value = model.C_MONTH; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_STA_CN GetModel(string C_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select C_ID,C_DATE,C_STA,C_VALUE,C_REMARK,N_STATUS,C_EMP_ID,D_MOD_DT,C_MONTH from TPB_STA_CN "); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = C_ID; Mod_TPB_STA_CN model = new Mod_TPB_STA_CN(); 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 Update(Mod_TPB_STA_CN model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_STA_CN model) { return(dal.Add(model)); }