private void ShowInfo() { MyERP.BLL.PUB_SUPPLY bll = new MyERP.BLL.PUB_SUPPLY(); MyERP.Model.PUB_SUPPLY model = bll.GetModel(); this.txtINTERNAL_CODE.Text = model.INTERNAL_CODE; this.txtSUPPLY_CODE.Text = model.SUPPLY_CODE; this.txtSUPPLY_NAME.Text = model.SUPPLY_NAME; this.txtPARENT_SUPPLY_CODE.Text = model.PARENT_SUPPLY_CODE; this.txtTypeCode.Text = model.TypeCode; this.txtTypeName.Text = model.TypeName; this.txtTELPHONE.Text = model.TELPHONE; this.txtTELPHONE1.Text = model.TELPHONE1; this.txtFAX.Text = model.FAX; this.txtEMAIL.Text = model.EMAIL; this.txtFULLNAME.Text = model.FULLNAME; this.txtADDRESS.Text = model.ADDRESS; this.txtEASYCODE.Text = model.EASYCODE; this.txtContact_MAN.Text = model.Contact_MAN; this.txtCREATE_NAME.Text = model.CREATE_NAME; this.txtCREATE_DATE.Text = model.CREATE_DATE.ToString(); this.txtUPDATE_NAME.Text = model.UPDATE_NAME; this.txtUPDATE_DATE.Text = model.UPDATE_DATE.ToString(); this.chkALLOW_used.Checked = model.ALLOW_used; this.txtREMARK.Text = model.REMARK; }
private void ShowInfo() { MyERP.BLL.PUB_SUPPLY bll = new MyERP.BLL.PUB_SUPPLY(); MyERP.Model.PUB_SUPPLY model = bll.GetModel(); this.lblINTERNAL_CODE.Text = model.INTERNAL_CODE; this.lblSUPPLY_CODE.Text = model.SUPPLY_CODE; this.lblSUPPLY_NAME.Text = model.SUPPLY_NAME; this.lblPARENT_SUPPLY_CODE.Text = model.PARENT_SUPPLY_CODE; this.lblTypeCode.Text = model.TypeCode; this.lblTypeName.Text = model.TypeName; this.lblTELPHONE.Text = model.TELPHONE; this.lblTELPHONE1.Text = model.TELPHONE1; this.lblFAX.Text = model.FAX; this.lblEMAIL.Text = model.EMAIL; this.lblFULLNAME.Text = model.FULLNAME; this.lblADDRESS.Text = model.ADDRESS; this.lblEASYCODE.Text = model.EASYCODE; this.lblContact_MAN.Text = model.Contact_MAN; this.lblCREATE_NAME.Text = model.CREATE_NAME; this.lblCREATE_DATE.Text = model.CREATE_DATE.ToString(); this.lblUPDATE_NAME.Text = model.UPDATE_NAME; this.lblUPDATE_DATE.Text = model.UPDATE_DATE.ToString(); this.lblALLOW_used.Text = model.ALLOW_used?"是":"否"; this.lblREMARK.Text = model.REMARK; }
/// <summary> /// 得到一个对象实体 /// </summary> public MyERP.Model.PUB_SUPPLY GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 INTERNAL_CODE,SUPPLY_CODE,SUPPLY_NAME,PARENT_SUPPLY_CODE,TypeCode,TypeName,TELPHONE,TELPHONE1,FAX,EMAIL,FULLNAME,ADDRESS,EASYCODE,Contact_MAN,CREATE_NAME,CREATE_DATE,UPDATE_NAME,UPDATE_DATE,ALLOW_used,REMARK from PUB_SUPPLY "); strSql.Append(" where "); SqlParameter[] parameters = { }; MyERP.Model.PUB_SUPPLY model = new MyERP.Model.PUB_SUPPLY(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtINTERNAL_CODE.Text.Trim().Length == 0) { strErr += "INTERNAL_CODE不能为空!\\n"; } if (this.txtSUPPLY_CODE.Text.Trim().Length == 0) { strErr += "SUPPLY_CODE不能为空!\\n"; } if (this.txtSUPPLY_NAME.Text.Trim().Length == 0) { strErr += "SUPPLY_NAME不能为空!\\n"; } if (this.txtPARENT_SUPPLY_CODE.Text.Trim().Length == 0) { strErr += "PARENT_SUPPLY_CODE不能为空!\\n"; } if (this.txtTypeCode.Text.Trim().Length == 0) { strErr += "TypeCode不能为空!\\n"; } if (this.txtTypeName.Text.Trim().Length == 0) { strErr += "TypeName不能为空!\\n"; } if (this.txtTELPHONE.Text.Trim().Length == 0) { strErr += "TELPHONE不能为空!\\n"; } if (this.txtTELPHONE1.Text.Trim().Length == 0) { strErr += "TELPHONE1不能为空!\\n"; } if (this.txtFAX.Text.Trim().Length == 0) { strErr += "FAX不能为空!\\n"; } if (this.txtEMAIL.Text.Trim().Length == 0) { strErr += "EMAIL不能为空!\\n"; } if (this.txtFULLNAME.Text.Trim().Length == 0) { strErr += "FULLNAME不能为空!\\n"; } if (this.txtADDRESS.Text.Trim().Length == 0) { strErr += "ADDRESS不能为空!\\n"; } if (this.txtEASYCODE.Text.Trim().Length == 0) { strErr += "EASYCODE不能为空!\\n"; } if (this.txtContact_MAN.Text.Trim().Length == 0) { strErr += "Contact_MAN不能为空!\\n"; } if (this.txtCREATE_NAME.Text.Trim().Length == 0) { strErr += "CREATE_NAME不能为空!\\n"; } if (!PageValidate.IsDateTime(txtCREATE_DATE.Text)) { strErr += "CREATE_DATE格式错误!\\n"; } if (this.txtUPDATE_NAME.Text.Trim().Length == 0) { strErr += "UPDATE_NAME不能为空!\\n"; } if (!PageValidate.IsDateTime(txtUPDATE_DATE.Text)) { strErr += "UPDATE_DATE格式错误!\\n"; } if (this.txtREMARK.Text.Trim().Length == 0) { strErr += "REMARK不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string INTERNAL_CODE = this.txtINTERNAL_CODE.Text; string SUPPLY_CODE = this.txtSUPPLY_CODE.Text; string SUPPLY_NAME = this.txtSUPPLY_NAME.Text; string PARENT_SUPPLY_CODE = this.txtPARENT_SUPPLY_CODE.Text; string TypeCode = this.txtTypeCode.Text; string TypeName = this.txtTypeName.Text; string TELPHONE = this.txtTELPHONE.Text; string TELPHONE1 = this.txtTELPHONE1.Text; string FAX = this.txtFAX.Text; string EMAIL = this.txtEMAIL.Text; string FULLNAME = this.txtFULLNAME.Text; string ADDRESS = this.txtADDRESS.Text; string EASYCODE = this.txtEASYCODE.Text; string Contact_MAN = this.txtContact_MAN.Text; string CREATE_NAME = this.txtCREATE_NAME.Text; DateTime CREATE_DATE = DateTime.Parse(this.txtCREATE_DATE.Text); string UPDATE_NAME = this.txtUPDATE_NAME.Text; DateTime UPDATE_DATE = DateTime.Parse(this.txtUPDATE_DATE.Text); bool ALLOW_used = this.chkALLOW_used.Checked; string REMARK = this.txtREMARK.Text; MyERP.Model.PUB_SUPPLY model = new MyERP.Model.PUB_SUPPLY(); model.INTERNAL_CODE = INTERNAL_CODE; model.SUPPLY_CODE = SUPPLY_CODE; model.SUPPLY_NAME = SUPPLY_NAME; model.PARENT_SUPPLY_CODE = PARENT_SUPPLY_CODE; model.TypeCode = TypeCode; model.TypeName = TypeName; model.TELPHONE = TELPHONE; model.TELPHONE1 = TELPHONE1; model.FAX = FAX; model.EMAIL = EMAIL; model.FULLNAME = FULLNAME; model.ADDRESS = ADDRESS; model.EASYCODE = EASYCODE; model.Contact_MAN = Contact_MAN; model.CREATE_NAME = CREATE_NAME; model.CREATE_DATE = CREATE_DATE; model.UPDATE_NAME = UPDATE_NAME; model.UPDATE_DATE = UPDATE_DATE; model.ALLOW_used = ALLOW_used; model.REMARK = REMARK; MyERP.BLL.PUB_SUPPLY bll = new MyERP.BLL.PUB_SUPPLY(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MyERP.Model.PUB_SUPPLY model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PUB_SUPPLY set "); strSql.Append("INTERNAL_CODE=@INTERNAL_CODE,"); strSql.Append("SUPPLY_CODE=@SUPPLY_CODE,"); strSql.Append("SUPPLY_NAME=@SUPPLY_NAME,"); strSql.Append("PARENT_SUPPLY_CODE=@PARENT_SUPPLY_CODE,"); strSql.Append("TypeCode=@TypeCode,"); strSql.Append("TypeName=@TypeName,"); strSql.Append("TELPHONE=@TELPHONE,"); strSql.Append("TELPHONE1=@TELPHONE1,"); strSql.Append("FAX=@FAX,"); strSql.Append("EMAIL=@EMAIL,"); strSql.Append("FULLNAME=@FULLNAME,"); strSql.Append("ADDRESS=@ADDRESS,"); strSql.Append("EASYCODE=@EASYCODE,"); strSql.Append("Contact_MAN=@Contact_MAN,"); strSql.Append("CREATE_NAME=@CREATE_NAME,"); strSql.Append("CREATE_DATE=@CREATE_DATE,"); strSql.Append("UPDATE_NAME=@UPDATE_NAME,"); strSql.Append("UPDATE_DATE=@UPDATE_DATE,"); strSql.Append("ALLOW_used=@ALLOW_used,"); strSql.Append("REMARK=@REMARK"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@INTERNAL_CODE", SqlDbType.NVarChar, 50), new SqlParameter("@SUPPLY_CODE", SqlDbType.NVarChar, 50), new SqlParameter("@SUPPLY_NAME", SqlDbType.NVarChar, 50), new SqlParameter("@PARENT_SUPPLY_CODE", SqlDbType.NVarChar, 50), new SqlParameter("@TypeCode", SqlDbType.NVarChar, 50), new SqlParameter("@TypeName", SqlDbType.NVarChar, 50), new SqlParameter("@TELPHONE", SqlDbType.NVarChar, 50), new SqlParameter("@TELPHONE1", SqlDbType.NVarChar, 50), new SqlParameter("@FAX", SqlDbType.NVarChar, 50), new SqlParameter("@EMAIL", SqlDbType.NVarChar, 50), new SqlParameter("@FULLNAME", SqlDbType.NVarChar, 50), new SqlParameter("@ADDRESS", SqlDbType.NVarChar, 50), new SqlParameter("@EASYCODE", SqlDbType.NVarChar, 50), new SqlParameter("@Contact_MAN", SqlDbType.NVarChar, 50), new SqlParameter("@CREATE_NAME", SqlDbType.NVarChar, 50), new SqlParameter("@CREATE_DATE", SqlDbType.DateTime), new SqlParameter("@UPDATE_NAME", SqlDbType.NVarChar, 50), new SqlParameter("@UPDATE_DATE", SqlDbType.DateTime), new SqlParameter("@ALLOW_used", SqlDbType.Bit, 1), new SqlParameter("@REMARK", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.INTERNAL_CODE; parameters[1].Value = model.SUPPLY_CODE; parameters[2].Value = model.SUPPLY_NAME; parameters[3].Value = model.PARENT_SUPPLY_CODE; parameters[4].Value = model.TypeCode; parameters[5].Value = model.TypeName; parameters[6].Value = model.TELPHONE; parameters[7].Value = model.TELPHONE1; parameters[8].Value = model.FAX; parameters[9].Value = model.EMAIL; parameters[10].Value = model.FULLNAME; parameters[11].Value = model.ADDRESS; parameters[12].Value = model.EASYCODE; parameters[13].Value = model.Contact_MAN; parameters[14].Value = model.CREATE_NAME; parameters[15].Value = model.CREATE_DATE; parameters[16].Value = model.UPDATE_NAME; parameters[17].Value = model.UPDATE_DATE; parameters[18].Value = model.ALLOW_used; parameters[19].Value = model.REMARK; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(MyERP.Model.PUB_SUPPLY model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PUB_SUPPLY("); strSql.Append("INTERNAL_CODE,SUPPLY_CODE,SUPPLY_NAME,PARENT_SUPPLY_CODE,TypeCode,TypeName,TELPHONE,TELPHONE1,FAX,EMAIL,FULLNAME,ADDRESS,EASYCODE,Contact_MAN,CREATE_NAME,CREATE_DATE,UPDATE_NAME,UPDATE_DATE,ALLOW_used,REMARK)"); strSql.Append(" values ("); strSql.Append("@INTERNAL_CODE,@SUPPLY_CODE,@SUPPLY_NAME,@PARENT_SUPPLY_CODE,@TypeCode,@TypeName,@TELPHONE,@TELPHONE1,@FAX,@EMAIL,@FULLNAME,@ADDRESS,@EASYCODE,@Contact_MAN,@CREATE_NAME,@CREATE_DATE,@UPDATE_NAME,@UPDATE_DATE,@ALLOW_used,@REMARK)"); SqlParameter[] parameters = { new SqlParameter("@INTERNAL_CODE", SqlDbType.NVarChar, 50), new SqlParameter("@SUPPLY_CODE", SqlDbType.NVarChar, 50), new SqlParameter("@SUPPLY_NAME", SqlDbType.NVarChar, 50), new SqlParameter("@PARENT_SUPPLY_CODE", SqlDbType.NVarChar, 50), new SqlParameter("@TypeCode", SqlDbType.NVarChar, 50), new SqlParameter("@TypeName", SqlDbType.NVarChar, 50), new SqlParameter("@TELPHONE", SqlDbType.NVarChar, 50), new SqlParameter("@TELPHONE1", SqlDbType.NVarChar, 50), new SqlParameter("@FAX", SqlDbType.NVarChar, 50), new SqlParameter("@EMAIL", SqlDbType.NVarChar, 50), new SqlParameter("@FULLNAME", SqlDbType.NVarChar, 50), new SqlParameter("@ADDRESS", SqlDbType.NVarChar, 50), new SqlParameter("@EASYCODE", SqlDbType.NVarChar, 50), new SqlParameter("@Contact_MAN", SqlDbType.NVarChar, 50), new SqlParameter("@CREATE_NAME", SqlDbType.NVarChar, 50), new SqlParameter("@CREATE_DATE", SqlDbType.DateTime), new SqlParameter("@UPDATE_NAME", SqlDbType.NVarChar, 50), new SqlParameter("@UPDATE_DATE", SqlDbType.DateTime), new SqlParameter("@ALLOW_used", SqlDbType.Bit, 1), new SqlParameter("@REMARK", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.INTERNAL_CODE; parameters[1].Value = model.SUPPLY_CODE; parameters[2].Value = model.SUPPLY_NAME; parameters[3].Value = model.PARENT_SUPPLY_CODE; parameters[4].Value = model.TypeCode; parameters[5].Value = model.TypeName; parameters[6].Value = model.TELPHONE; parameters[7].Value = model.TELPHONE1; parameters[8].Value = model.FAX; parameters[9].Value = model.EMAIL; parameters[10].Value = model.FULLNAME; parameters[11].Value = model.ADDRESS; parameters[12].Value = model.EASYCODE; parameters[13].Value = model.Contact_MAN; parameters[14].Value = model.CREATE_NAME; parameters[15].Value = model.CREATE_DATE; parameters[16].Value = model.UPDATE_NAME; parameters[17].Value = model.UPDATE_DATE; parameters[18].Value = model.ALLOW_used; parameters[19].Value = model.REMARK; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MyERP.Model.PUB_SUPPLY DataRowToModel(DataRow row) { MyERP.Model.PUB_SUPPLY model = new MyERP.Model.PUB_SUPPLY(); if (row != null) { if (row["INTERNAL_CODE"] != null) { model.INTERNAL_CODE = row["INTERNAL_CODE"].ToString(); } if (row["SUPPLY_CODE"] != null) { model.SUPPLY_CODE = row["SUPPLY_CODE"].ToString(); } if (row["SUPPLY_NAME"] != null) { model.SUPPLY_NAME = row["SUPPLY_NAME"].ToString(); } if (row["PARENT_SUPPLY_CODE"] != null) { model.PARENT_SUPPLY_CODE = row["PARENT_SUPPLY_CODE"].ToString(); } if (row["TypeCode"] != null) { model.TypeCode = row["TypeCode"].ToString(); } if (row["TypeName"] != null) { model.TypeName = row["TypeName"].ToString(); } if (row["TELPHONE"] != null) { model.TELPHONE = row["TELPHONE"].ToString(); } if (row["TELPHONE1"] != null) { model.TELPHONE1 = row["TELPHONE1"].ToString(); } if (row["FAX"] != null) { model.FAX = row["FAX"].ToString(); } if (row["EMAIL"] != null) { model.EMAIL = row["EMAIL"].ToString(); } if (row["FULLNAME"] != null) { model.FULLNAME = row["FULLNAME"].ToString(); } if (row["ADDRESS"] != null) { model.ADDRESS = row["ADDRESS"].ToString(); } if (row["EASYCODE"] != null) { model.EASYCODE = row["EASYCODE"].ToString(); } if (row["Contact_MAN"] != null) { model.Contact_MAN = row["Contact_MAN"].ToString(); } if (row["CREATE_NAME"] != null) { model.CREATE_NAME = row["CREATE_NAME"].ToString(); } if (row["CREATE_DATE"] != null && row["CREATE_DATE"].ToString() != "") { model.CREATE_DATE = DateTime.Parse(row["CREATE_DATE"].ToString()); } if (row["UPDATE_NAME"] != null) { model.UPDATE_NAME = row["UPDATE_NAME"].ToString(); } if (row["UPDATE_DATE"] != null && row["UPDATE_DATE"].ToString() != "") { model.UPDATE_DATE = DateTime.Parse(row["UPDATE_DATE"].ToString()); } if (row["ALLOW_used"] != null && row["ALLOW_used"].ToString() != "") { if ((row["ALLOW_used"].ToString() == "1") || (row["ALLOW_used"].ToString().ToLower() == "true")) { model.ALLOW_used = true; } else { model.ALLOW_used = false; } } if (row["REMARK"] != null) { model.REMARK = row["REMARK"].ToString(); } } return(model); }