/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TQB_PHYSICS_GROUP_STD GetModel(string C_PHYSICS_CODE, string C_STD_CODE, string C_STL_GRD) { StringBuilder strSql = new StringBuilder(); strSql.Append("select C_ID,C_PHYSICS_CODE,C_PHYSICS_NAME,C_STL_GRD,C_STD_CODE,N_STATUS,C_REMARK,C_EMP_ID,D_MOD_DT from TQB_PHYSICS_GROUP_STD "); strSql.Append(" where C_PHYSICS_CODE=:C_PHYSICS_CODE and C_STD_CODE=:C_STD_CODE and C_STL_GRD=:C_STL_GRD "); OracleParameter[] parameters = { new OracleParameter(":C_PHYSICS_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 100) }; parameters[0].Value = C_PHYSICS_CODE; parameters[0].Value = C_STD_CODE; parameters[0].Value = C_STL_GRD; Mod_TQB_PHYSICS_GROUP_STD model = new Mod_TQB_PHYSICS_GROUP_STD(); 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> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Add_Click(object sender, EventArgs e) { try { int[] rownumber = gv_Bz.GetSelectedRows();//获取选中行号数组; if (rownumber.Length > 0) { DialogResult dialogResult = MessageBox.Show("确认添加吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (dialogResult == DialogResult.OK) { int num_Success = 0; string strUserID = RV.UI.UserInfo.userID; for (int i = 0; i < rownumber.Length; i++) { string strZXBZ = gv_Bz.GetRowCellValue(rownumber[i], "C_STD_CODE").ToString(); string strGZ = gv_Bz.GetRowCellValue(rownumber[i], "C_STL_GRD").ToString(); Mod_TQB_PHYSICS_GROUP_STD model = bllTqbPhysicsGroupStd.GetModel(strCode, strZXBZ, strGZ); if (model == null) { model = new Mod_TQB_PHYSICS_GROUP_STD(); model.C_PHYSICS_CODE = strCode; model.C_PHYSICS_NAME = strName; model.C_STD_CODE = strZXBZ; model.C_STL_GRD = strGZ; model.C_EMP_ID = strUserID; if (bllTqbPhysicsGroupStd.Add(model)) { num_Success++; Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "添加物理性能" + strCode + strName + "与执行标准" + strZXBZ + "钢种" + strGZ + "的匹配关系 ");//添加操作日志 } } } MessageBox.Show("共{" + rownumber.Length + "}条记录,添加成功{" + num_Success + "}条"); BindWLBZ(strCode); BindStdMain(); } } else { MessageBox.Show("请选择需要添加的数据"); return; } } catch { } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TQB_PHYSICS_GROUP_STD model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TQB_PHYSICS_GROUP_STD set "); strSql.Append("C_PHYSICS_CODE=:C_PHYSICS_CODE,"); strSql.Append("C_PHYSICS_NAME=:C_PHYSICS_NAME,"); strSql.Append("C_STL_GRD=:C_STL_GRD,"); strSql.Append("C_STD_CODE=:C_STD_CODE,"); strSql.Append("N_STATUS=:N_STATUS,"); strSql.Append("C_REMARK=:C_REMARK,"); strSql.Append("C_EMP_ID=:C_EMP_ID,"); strSql.Append("D_MOD_DT=:D_MOD_DT"); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_PHYSICS_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_PHYSICS_NAME", OracleDbType.Varchar2, 100), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 100), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":N_STATUS", OracleDbType.Int32, 1), new OracleParameter(":C_REMARK", OracleDbType.Varchar2, 500), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100), new OracleParameter(":D_MOD_DT", OracleDbType.Date), new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_PHYSICS_CODE; parameters[1].Value = model.C_PHYSICS_NAME; parameters[2].Value = model.C_STL_GRD; parameters[3].Value = model.C_STD_CODE; parameters[4].Value = model.N_STATUS; parameters[5].Value = model.C_REMARK; parameters[6].Value = model.C_EMP_ID; parameters[7].Value = model.D_MOD_DT; parameters[8].Value = model.C_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TQB_PHYSICS_GROUP_STD DataRowToModel(DataRow row) { Mod_TQB_PHYSICS_GROUP_STD model = new Mod_TQB_PHYSICS_GROUP_STD(); if (row != null) { if (row["C_ID"] != null) { model.C_ID = row["C_ID"].ToString(); } if (row["C_PHYSICS_CODE"] != null) { model.C_PHYSICS_CODE = row["C_PHYSICS_CODE"].ToString(); } if (row["C_PHYSICS_NAME"] != null) { model.C_PHYSICS_NAME = row["C_PHYSICS_NAME"].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["N_STATUS"] != null && row["N_STATUS"].ToString() != "") { model.N_STATUS = decimal.Parse(row["N_STATUS"].ToString()); } if (row["C_REMARK"] != null) { model.C_REMARK = row["C_REMARK"].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()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TQB_PHYSICS_GROUP_STD model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TQB_PHYSICS_GROUP_STD("); strSql.Append("C_PHYSICS_CODE,C_PHYSICS_NAME,C_STL_GRD,C_STD_CODE,N_STATUS,C_REMARK,C_EMP_ID)"); strSql.Append(" values ("); strSql.Append(":C_PHYSICS_CODE,:C_PHYSICS_NAME,:C_STL_GRD,:C_STD_CODE,:N_STATUS,:C_REMARK,:C_EMP_ID)"); OracleParameter[] parameters = { new OracleParameter(":C_PHYSICS_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_PHYSICS_NAME", OracleDbType.Varchar2, 100), new OracleParameter(":C_STL_GRD", OracleDbType.Varchar2, 100), new OracleParameter(":C_STD_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":N_STATUS", OracleDbType.Int32, 1), new OracleParameter(":C_REMARK", OracleDbType.Varchar2, 500), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_PHYSICS_CODE; parameters[1].Value = model.C_PHYSICS_NAME; parameters[2].Value = model.C_STL_GRD; parameters[3].Value = model.C_STD_CODE; parameters[4].Value = model.N_STATUS; parameters[5].Value = model.C_REMARK; parameters[6].Value = model.C_EMP_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TQB_PHYSICS_GROUP_STD model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TQB_PHYSICS_GROUP_STD model) { return(dal.Add(model)); }