/// <summary> /// 增加一条数据 /// </summary> public bool Add(MyERP.Model.ORDER_SEND_REMARK model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ORDER_SEND_REMARK("); strSql.Append("MASTERID,BILLNO,Sequence,MANUAL_BILLNO,Vehicle_CODE,Vehicle_NAME,STOCK_CODE,STOCK_NAME,DEPARTMENT_CODE,DEPARTMENT_NAME,CREATE_CODE,CREATE_NAME,CREATE_DATE,REMARK)"); strSql.Append(" values ("); strSql.Append("@MASTERID,@BILLNO,@Sequence,@MANUAL_BILLNO,@Vehicle_CODE,@Vehicle_NAME,@STOCK_CODE,@STOCK_NAME,@DEPARTMENT_CODE,@DEPARTMENT_NAME,@CREATE_CODE,@CREATE_NAME,@CREATE_DATE,@REMARK)"); SqlParameter[] parameters = { new SqlParameter("@MASTERID", SqlDbType.VarChar, 50), new SqlParameter("@BILLNO", SqlDbType.VarChar, 50), new SqlParameter("@Sequence", SqlDbType.Int, 4), new SqlParameter("@MANUAL_BILLNO", SqlDbType.VarChar, 50), new SqlParameter("@Vehicle_CODE", SqlDbType.VarChar, 50), new SqlParameter("@Vehicle_NAME", SqlDbType.VarChar, 50), new SqlParameter("@STOCK_CODE", SqlDbType.VarChar, 50), new SqlParameter("@STOCK_NAME", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENT_CODE", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENT_NAME", SqlDbType.VarChar, 50), new SqlParameter("@CREATE_CODE", SqlDbType.VarChar, 50), new SqlParameter("@CREATE_NAME", SqlDbType.VarChar, 50), new SqlParameter("@CREATE_DATE", SqlDbType.DateTime), new SqlParameter("@REMARK", SqlDbType.VarChar, 200) }; parameters[0].Value = model.MASTERID; parameters[1].Value = model.BILLNO; parameters[2].Value = model.Sequence; parameters[3].Value = model.MANUAL_BILLNO; parameters[4].Value = model.Vehicle_CODE; parameters[5].Value = model.Vehicle_NAME; parameters[6].Value = model.STOCK_CODE; parameters[7].Value = model.STOCK_NAME; parameters[8].Value = model.DEPARTMENT_CODE; parameters[9].Value = model.DEPARTMENT_NAME; parameters[10].Value = model.CREATE_CODE; parameters[11].Value = model.CREATE_NAME; parameters[12].Value = model.CREATE_DATE; parameters[13].Value = model.REMARK; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo() { MyERP.BLL.ORDER_SEND_REMARK bll = new MyERP.BLL.ORDER_SEND_REMARK(); MyERP.Model.ORDER_SEND_REMARK model = bll.GetModel(); this.lblMASTERID.Text = model.MASTERID; this.lblBILLNO.Text = model.BILLNO; this.lblSequence.Text = model.Sequence.ToString(); this.lblMANUAL_BILLNO.Text = model.MANUAL_BILLNO; this.lblVehicle_CODE.Text = model.Vehicle_CODE; this.lblVehicle_NAME.Text = model.Vehicle_NAME; this.lblSTOCK_CODE.Text = model.STOCK_CODE; this.lblSTOCK_NAME.Text = model.STOCK_NAME; this.lblDEPARTMENT_CODE.Text = model.DEPARTMENT_CODE; this.lblDEPARTMENT_NAME.Text = model.DEPARTMENT_NAME; this.lblCREATE_CODE.Text = model.CREATE_CODE; this.lblCREATE_NAME.Text = model.CREATE_NAME; this.lblCREATE_DATE.Text = model.CREATE_DATE.ToString(); this.lblREMARK.Text = model.REMARK; }
/// <summary> /// 得到一个对象实体 /// </summary> public MyERP.Model.ORDER_SEND_REMARK GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 MASTERID,BILLNO,Sequence,MANUAL_BILLNO,Vehicle_CODE,Vehicle_NAME,STOCK_CODE,STOCK_NAME,DEPARTMENT_CODE,DEPARTMENT_NAME,CREATE_CODE,CREATE_NAME,CREATE_DATE,REMARK from ORDER_SEND_REMARK "); strSql.Append(" where "); SqlParameter[] parameters = { }; MyERP.Model.ORDER_SEND_REMARK model = new MyERP.Model.ORDER_SEND_REMARK(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtMASTERID.Text.Trim().Length == 0) { strErr += "MASTERID不能为空!\\n"; } if (this.txtBILLNO.Text.Trim().Length == 0) { strErr += "BILLNO不能为空!\\n"; } if (!PageValidate.IsNumber(txtSequence.Text)) { strErr += "Sequence格式错误!\\n"; } if (this.txtMANUAL_BILLNO.Text.Trim().Length == 0) { strErr += "MANUAL_BILLNO不能为空!\\n"; } if (this.txtVehicle_CODE.Text.Trim().Length == 0) { strErr += "Vehicle_CODE不能为空!\\n"; } if (this.txtVehicle_NAME.Text.Trim().Length == 0) { strErr += "Vehicle_NAME不能为空!\\n"; } if (this.txtSTOCK_CODE.Text.Trim().Length == 0) { strErr += "STOCK_CODE不能为空!\\n"; } if (this.txtSTOCK_NAME.Text.Trim().Length == 0) { strErr += "STOCK_NAME不能为空!\\n"; } if (this.txtDEPARTMENT_CODE.Text.Trim().Length == 0) { strErr += "DEPARTMENT_CODE不能为空!\\n"; } if (this.txtDEPARTMENT_NAME.Text.Trim().Length == 0) { strErr += "DEPARTMENT_NAME不能为空!\\n"; } if (this.txtCREATE_CODE.Text.Trim().Length == 0) { strErr += "CREATE_CODE不能为空!\\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.txtREMARK.Text.Trim().Length == 0) { strErr += "REMARK不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string MASTERID = this.txtMASTERID.Text; string BILLNO = this.txtBILLNO.Text; int Sequence = int.Parse(this.txtSequence.Text); string MANUAL_BILLNO = this.txtMANUAL_BILLNO.Text; string Vehicle_CODE = this.txtVehicle_CODE.Text; string Vehicle_NAME = this.txtVehicle_NAME.Text; string STOCK_CODE = this.txtSTOCK_CODE.Text; string STOCK_NAME = this.txtSTOCK_NAME.Text; string DEPARTMENT_CODE = this.txtDEPARTMENT_CODE.Text; string DEPARTMENT_NAME = this.txtDEPARTMENT_NAME.Text; string CREATE_CODE = this.txtCREATE_CODE.Text; string CREATE_NAME = this.txtCREATE_NAME.Text; DateTime CREATE_DATE = DateTime.Parse(this.txtCREATE_DATE.Text); string REMARK = this.txtREMARK.Text; MyERP.Model.ORDER_SEND_REMARK model = new MyERP.Model.ORDER_SEND_REMARK(); model.MASTERID = MASTERID; model.BILLNO = BILLNO; model.Sequence = Sequence; model.MANUAL_BILLNO = MANUAL_BILLNO; model.Vehicle_CODE = Vehicle_CODE; model.Vehicle_NAME = Vehicle_NAME; model.STOCK_CODE = STOCK_CODE; model.STOCK_NAME = STOCK_NAME; model.DEPARTMENT_CODE = DEPARTMENT_CODE; model.DEPARTMENT_NAME = DEPARTMENT_NAME; model.CREATE_CODE = CREATE_CODE; model.CREATE_NAME = CREATE_NAME; model.CREATE_DATE = CREATE_DATE; model.REMARK = REMARK; MyERP.BLL.ORDER_SEND_REMARK bll = new MyERP.BLL.ORDER_SEND_REMARK(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MyERP.Model.ORDER_SEND_REMARK model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ORDER_SEND_REMARK set "); strSql.Append("MASTERID=@MASTERID,"); strSql.Append("BILLNO=@BILLNO,"); strSql.Append("Sequence=@Sequence,"); strSql.Append("MANUAL_BILLNO=@MANUAL_BILLNO,"); strSql.Append("Vehicle_CODE=@Vehicle_CODE,"); strSql.Append("Vehicle_NAME=@Vehicle_NAME,"); strSql.Append("STOCK_CODE=@STOCK_CODE,"); strSql.Append("STOCK_NAME=@STOCK_NAME,"); strSql.Append("DEPARTMENT_CODE=@DEPARTMENT_CODE,"); strSql.Append("DEPARTMENT_NAME=@DEPARTMENT_NAME,"); strSql.Append("CREATE_CODE=@CREATE_CODE,"); strSql.Append("CREATE_NAME=@CREATE_NAME,"); strSql.Append("CREATE_DATE=@CREATE_DATE,"); strSql.Append("REMARK=@REMARK"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@MASTERID", SqlDbType.VarChar, 50), new SqlParameter("@BILLNO", SqlDbType.VarChar, 50), new SqlParameter("@Sequence", SqlDbType.Int, 4), new SqlParameter("@MANUAL_BILLNO", SqlDbType.VarChar, 50), new SqlParameter("@Vehicle_CODE", SqlDbType.VarChar, 50), new SqlParameter("@Vehicle_NAME", SqlDbType.VarChar, 50), new SqlParameter("@STOCK_CODE", SqlDbType.VarChar, 50), new SqlParameter("@STOCK_NAME", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENT_CODE", SqlDbType.VarChar, 50), new SqlParameter("@DEPARTMENT_NAME", SqlDbType.VarChar, 50), new SqlParameter("@CREATE_CODE", SqlDbType.VarChar, 50), new SqlParameter("@CREATE_NAME", SqlDbType.VarChar, 50), new SqlParameter("@CREATE_DATE", SqlDbType.DateTime), new SqlParameter("@REMARK", SqlDbType.VarChar, 200) }; parameters[0].Value = model.MASTERID; parameters[1].Value = model.BILLNO; parameters[2].Value = model.Sequence; parameters[3].Value = model.MANUAL_BILLNO; parameters[4].Value = model.Vehicle_CODE; parameters[5].Value = model.Vehicle_NAME; parameters[6].Value = model.STOCK_CODE; parameters[7].Value = model.STOCK_NAME; parameters[8].Value = model.DEPARTMENT_CODE; parameters[9].Value = model.DEPARTMENT_NAME; parameters[10].Value = model.CREATE_CODE; parameters[11].Value = model.CREATE_NAME; parameters[12].Value = model.CREATE_DATE; parameters[13].Value = model.REMARK; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MyERP.Model.ORDER_SEND_REMARK DataRowToModel(DataRow row) { MyERP.Model.ORDER_SEND_REMARK model = new MyERP.Model.ORDER_SEND_REMARK(); if (row != null) { if (row["MASTERID"] != null) { model.MASTERID = row["MASTERID"].ToString(); } if (row["BILLNO"] != null) { model.BILLNO = row["BILLNO"].ToString(); } if (row["Sequence"] != null && row["Sequence"].ToString() != "") { model.Sequence = int.Parse(row["Sequence"].ToString()); } if (row["MANUAL_BILLNO"] != null) { model.MANUAL_BILLNO = row["MANUAL_BILLNO"].ToString(); } if (row["Vehicle_CODE"] != null) { model.Vehicle_CODE = row["Vehicle_CODE"].ToString(); } if (row["Vehicle_NAME"] != null) { model.Vehicle_NAME = row["Vehicle_NAME"].ToString(); } if (row["STOCK_CODE"] != null) { model.STOCK_CODE = row["STOCK_CODE"].ToString(); } if (row["STOCK_NAME"] != null) { model.STOCK_NAME = row["STOCK_NAME"].ToString(); } if (row["DEPARTMENT_CODE"] != null) { model.DEPARTMENT_CODE = row["DEPARTMENT_CODE"].ToString(); } if (row["DEPARTMENT_NAME"] != null) { model.DEPARTMENT_NAME = row["DEPARTMENT_NAME"].ToString(); } if (row["CREATE_CODE"] != null) { model.CREATE_CODE = row["CREATE_CODE"].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["REMARK"] != null) { model.REMARK = row["REMARK"].ToString(); } } return(model); }