/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TB_REHEATING_FURNACE model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TB_REHEATING_FURNACE("); strSql.Append("C_TYPE,N_HOUR,C_STL_GRD,C_STD_CODE,C_ZL_TYPE,D_MOD_DT,C_EMP_ID,C_BY1,C_BY2,C_BY3,C_BY4,C_BY5,C_BY6)"); strSql.Append(" values ("); strSql.Append(":C_TYPE,:N_HOUR,:C_STL_GRD,:C_STD_CODE,:C_ZL_TYPE,:D_MOD_DT,:C_EMP_ID,:C_BY1,:C_BY2,:C_BY3,:C_BY4,:C_BY5,:C_BY6)"); OracleParameter[] parameters = { new OracleParameter(":C_TYPE", OracleDbType.Varchar2, 50), new OracleParameter(":N_HOUR", OracleDbType.Decimal, 4), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 50), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 50), new OracleParameter(":C_ZL_TYPE", OracleDbType.Varchar2, 50), new OracleParameter(":D_MOD_DT", OracleDbType.Date), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_BY1", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY2", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY3", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY4", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY5", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY6", OracleDbType.Varchar2, 1000) }; parameters[0].Value = model.C_TYPE; parameters[1].Value = model.N_HOUR; parameters[2].Value = model.C_STL_GRD; parameters[3].Value = model.C_STD_CODE; parameters[4].Value = model.C_ZL_TYPE; parameters[5].Value = model.D_MOD_DT; parameters[6].Value = model.C_EMP_ID; parameters[7].Value = model.C_BY1; parameters[8].Value = model.C_BY2; parameters[9].Value = model.C_BY3; parameters[10].Value = model.C_BY4; parameters[11].Value = model.C_BY5; parameters[12].Value = model.C_BY6; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TB_REHEATING_FURNACE GetModel(string C_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select C_ID,C_TYPE,N_HOUR,C_STL_GRD,C_STD_CODE,C_ZL_TYPE,D_MOD_DT,C_EMP_ID,C_BY1,C_BY2,C_BY3,C_BY4,C_BY5,C_BY6 from TB_REHEATING_FURNACE "); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_ID", OracleDbType.Varchar2, 50) }; parameters[0].Value = C_ID; Mod_TB_REHEATING_FURNACE model = new Mod_TB_REHEATING_FURNACE(); 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_TB_REHEATING_FURNACE model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TB_REHEATING_FURNACE model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TB_REHEATING_FURNACE model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TB_REHEATING_FURNACE set "); strSql.Append("C_TYPE=:C_TYPE,"); strSql.Append("N_HOUR=:N_HOUR,"); strSql.Append("C_STL_GRD=:C_STL_GRD,"); strSql.Append("C_STD_CODE=:C_STD_CODE,"); strSql.Append("C_ZL_TYPE=:C_ZL_TYPE,"); strSql.Append("D_MOD_DT=:D_MOD_DT,"); strSql.Append("C_EMP_ID=:C_EMP_ID,"); strSql.Append("C_BY1=:C_BY1,"); strSql.Append("C_BY2=:C_BY2,"); strSql.Append("C_BY3=:C_BY3,"); strSql.Append("C_BY4=:C_BY4,"); strSql.Append("C_BY5=:C_BY5,"); strSql.Append("C_BY6=:C_BY6"); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_TYPE", OracleDbType.Varchar2, 50), new OracleParameter(":N_HOUR", OracleDbType.Decimal, 4), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 50), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 50), new OracleParameter(":C_ZL_TYPE", OracleDbType.Varchar2, 50), new OracleParameter(":D_MOD_DT", OracleDbType.Date), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_BY1", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY2", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY3", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY4", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY5", OracleDbType.Varchar2, 1000), new OracleParameter(":C_BY6", OracleDbType.Varchar2, 1000), new OracleParameter(":C_ID", OracleDbType.Varchar2, 50) }; parameters[0].Value = model.C_TYPE; parameters[1].Value = model.N_HOUR; parameters[2].Value = model.C_STL_GRD; parameters[3].Value = model.C_STD_CODE; parameters[4].Value = model.C_ZL_TYPE; parameters[5].Value = model.D_MOD_DT; parameters[6].Value = model.C_EMP_ID; parameters[7].Value = model.C_BY1; parameters[8].Value = model.C_BY2; parameters[9].Value = model.C_BY3; parameters[10].Value = model.C_BY4; parameters[11].Value = model.C_BY5; parameters[12].Value = model.C_BY6; parameters[13].Value = model.C_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TB_REHEATING_FURNACE DataRowToModel(DataRow row) { Mod_TB_REHEATING_FURNACE model = new Mod_TB_REHEATING_FURNACE(); if (row != null) { if (row["C_ID"] != null) { model.C_ID = row["C_ID"].ToString(); } if (row["C_TYPE"] != null) { model.C_TYPE = row["C_TYPE"].ToString(); } if (row["N_HOUR"] != null && row["N_HOUR"].ToString() != "") { model.N_HOUR = decimal.Parse(row["N_HOUR"].ToString()); } if (row["C_STL_GRD"] != null) { model.C_STL_GRD = row["C_STL_GRD"].ToString(); } if (row["C_STD_CODE"] != null) { model.C_STD_CODE = row["C_STD_CODE"].ToString(); } if (row["C_ZL_TYPE"] != null) { model.C_ZL_TYPE = row["C_ZL_TYPE"].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_EMP_ID"] != null) { model.C_EMP_ID = row["C_EMP_ID"].ToString(); } if (row["C_BY1"] != null) { model.C_BY1 = row["C_BY1"].ToString(); } if (row["C_BY2"] != null) { model.C_BY2 = row["C_BY2"].ToString(); } if (row["C_BY3"] != null) { model.C_BY3 = row["C_BY3"].ToString(); } if (row["C_BY4"] != null) { model.C_BY4 = row["C_BY4"].ToString(); } if (row["C_BY5"] != null) { model.C_BY5 = row["C_BY5"].ToString(); } if (row["C_BY6"] != null) { model.C_BY6 = row["C_BY6"].ToString(); } } return(model); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Save_Click(object sender, EventArgs e) { try { int[] rownumber = gv_StdMain.GetSelectedRows();//获取选中行号数组; if (rownumber.Length == 0) { MessageBox.Show("请选择需要保存的信息!"); return; } if (imgcbo_Time.EditValue == null) { MessageBox.Show("加热时间不能为空!", "提示"); return; } if (DialogResult.OK != MessageBox.Show("是否确认保存已选中的数据?", "提示", MessageBoxButtons.OKCancel)) { return; } for (int i = 0; i < rownumber.Length; i++) { DataRow dr = gv_StdMain.GetDataRow(rownumber[i]); Mod_TB_REHEATING_FURNACE mod = new Mod_TB_REHEATING_FURNACE(); if (rbtn_isty_wh.SelectedIndex == 0) { mod.C_ZL_TYPE = "热装"; } if (rbtn_isty_wh.SelectedIndex == 1) { mod.C_ZL_TYPE = "冷装"; } mod.C_STL_GRD = dr["C_STL_GRD"].ToString(); mod.C_STD_CODE = dr["C_STD_CODE"].ToString(); mod.N_HOUR = Convert.ToDecimal(imgcbo_Time.EditValue); mod.C_BY1 = txt_remark.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_STL_GRD", mod.C_STL_GRD); ht.Add("C_STD_CODE", mod.C_STD_CODE); ht.Add("N_HOUR", mod.N_HOUR); ht.Add("C_ZL_TYPE", mod.C_ZL_TYPE); if (Common.CheckRepeat.CheckTable("TB_REHEATING_FURNACE", ht) > 0) { MessageBox.Show("已存在,不能重复添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endregion bllReheting.Add(mod); } MessageBox.Show("保存成功!", "提示"); NewMethod(); NewMethod1(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }