/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_HOOK model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TPB_HOOK("); strSql.Append("C_STA_ID,N_HOOK_NO,N_STATUS,C_EMP_ID,D_MOD_DT,C_REMARK)"); strSql.Append(" values ("); strSql.Append(":C_STA_ID,:N_HOOK_NO,:N_STATUS,:C_EMP_ID,:D_MOD_DT,:C_REMARK)"); OracleParameter[] parameters = { new OracleParameter(":C_STA_ID", OracleDbType.Varchar2, 100), new OracleParameter(":N_HOOK_NO", OracleDbType.Decimal, 5), 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_REMARK", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_STA_ID; parameters[1].Value = model.N_HOOK_NO; parameters[2].Value = model.N_STATUS; parameters[3].Value = model.C_EMP_ID; parameters[4].Value = model.D_MOD_DT; parameters[5].Value = model.C_REMARK; 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_Add_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(imgcbo_CX.Text.Trim())) { MessageBox.Show("产线不能为空!"); return; } if (string.IsNullOrEmpty(txt_GH.Text.Trim())) { MessageBox.Show("钩号不能为空!"); return; } if (txt_GH.Text.Trim() == "0") { MessageBox.Show("钩号不能为0!"); return; } try { Mod_TPB_HOOK mod = new Mod_TPB_HOOK(); mod.C_STA_ID = imgcbo_CX.EditValue.ToString(); mod.N_HOOK_NO = Convert.ToInt32(txt_GH.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_STA_ID", imgcbo_CX.EditValue.ToString()); ht.Add("N_HOOK_NO", txt_GH.Text.Trim()); ht.Add("N_STATUS", 1); if (Common.CheckRepeat.CheckTable("TPB_HOOK", ht) > 0) { MessageBox.Show("已存在,不能重复添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endregion if (bll_hook.Add(mod)) { Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "添加钩号");//添加操作日志 MessageBox.Show("添加成功!"); NewMethod(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TPB_HOOK model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TPB_HOOK set "); strSql.Append("C_STA_ID=:C_STA_ID,"); strSql.Append("N_HOOK_NO=:N_HOOK_NO,"); 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_REMARK=:C_REMARK"); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_STA_ID", OracleDbType.Varchar2, 100), new OracleParameter(":N_HOOK_NO", OracleDbType.Decimal, 5), 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_REMARK", OracleDbType.Varchar2, 100), new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_STA_ID; parameters[1].Value = model.N_HOOK_NO; parameters[2].Value = model.N_STATUS; parameters[3].Value = model.C_EMP_ID; parameters[4].Value = model.D_MOD_DT; parameters[5].Value = model.C_REMARK; parameters[6].Value = model.C_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_HOOK DataRowToModel(DataRow row) { Mod_TPB_HOOK model = new Mod_TPB_HOOK(); 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["N_HOOK_NO"] != null && row["N_HOOK_NO"].ToString() != "") { model.N_HOOK_NO = decimal.Parse(row["N_HOOK_NO"].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_REMARK"] != null) { model.C_REMARK = row["C_REMARK"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_HOOK GetModel(string C_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select C_ID,C_STA_ID,N_HOOK_NO,N_STATUS,C_EMP_ID,D_MOD_DT,C_REMARK from TPB_HOOK "); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = C_ID; Mod_TPB_HOOK model = new Mod_TPB_HOOK(); 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_HOOK model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_HOOK model) { return(dal.Add(model)); }