/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.InvoiceNumInfo DataRowToModel(DataRow row) { WebDemo.Model.WebDemo.InvoiceNumInfo model = new WebDemo.Model.WebDemo.InvoiceNumInfo(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["DisId"] != null && row["DisId"].ToString() != "") { model.DisId = int.Parse(row["DisId"].ToString()); } if (row["BatchId"] != null && row["BatchId"].ToString() != "") { model.BatchId = int.Parse(row["BatchId"].ToString()); } if (row["InCode"] != null) { model.InCode = row["InCode"].ToString(); } if (row["InvoiceNum"] != null) { model.InvoiceNum = row["InvoiceNum"].ToString(); } if (row["OrderNum"] != null) { model.OrderNum = row["OrderNum"].ToString(); } if (row["Mark"] != null && row["Mark"].ToString() != "") { model.Mark = int.Parse(row["Mark"].ToString()); } if (row["SubFlag"] != null && row["SubFlag"].ToString() != "") { model.SubFlag = int.Parse(row["SubFlag"].ToString()); } if (row["OperatorID"] != null && row["OperatorID"].ToString() != "") { model.OperatorID = int.Parse(row["OperatorID"].ToString()); } if (row["AssignOperator"] != null) { model.AssignOperator = row["AssignOperator"].ToString(); } if (row["AssignDate"] != null && row["AssignDate"].ToString() != "") { model.AssignDate = DateTime.Parse(row["AssignDate"].ToString()); } if (row["OperDate"] != null && row["OperDate"].ToString() != "") { model.OperDate = DateTime.Parse(row["OperDate"].ToString()); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WebDemo.Model.WebDemo.InvoiceNumInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update InvoiceNumInfo set "); strSql.Append("DisId=@DisId,"); strSql.Append("BatchId=@BatchId,"); strSql.Append("InCode=@InCode,"); strSql.Append("InvoiceNum=@InvoiceNum,"); strSql.Append("OrderNum=@OrderNum,"); strSql.Append("Mark=@Mark,"); strSql.Append("SubFlag=@SubFlag,"); strSql.Append("OperatorID=@OperatorID,"); strSql.Append("AssignOperator=@AssignOperator,"); strSql.Append("AssignDate=@AssignDate,"); strSql.Append("OperDate=@OperDate,"); strSql.Append("Remark=@Remark"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@DisId", SqlDbType.Int, 4), new SqlParameter("@BatchId", SqlDbType.Int, 4), new SqlParameter("@InCode", SqlDbType.VarChar, 50), new SqlParameter("@InvoiceNum", SqlDbType.VarChar, 50), new SqlParameter("@OrderNum", SqlDbType.VarChar, 50), new SqlParameter("@Mark", SqlDbType.Int, 4), new SqlParameter("@SubFlag", SqlDbType.Int, 4), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@AssignOperator", SqlDbType.VarChar, 50), new SqlParameter("@AssignDate", SqlDbType.DateTime), new SqlParameter("@OperDate", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.VarChar, 200), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.DisId; parameters[1].Value = model.BatchId; parameters[2].Value = model.InCode; parameters[3].Value = model.InvoiceNum; parameters[4].Value = model.OrderNum; parameters[5].Value = model.Mark; parameters[6].Value = model.SubFlag; parameters[7].Value = model.OperatorID; parameters[8].Value = model.AssignOperator; parameters[9].Value = model.AssignDate; parameters[10].Value = model.OperDate; parameters[11].Value = model.Remark; parameters[12].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WebDemo.Model.WebDemo.InvoiceNumInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into InvoiceNumInfo("); strSql.Append("DisId,BatchId,InCode,InvoiceNum,OrderNum,Mark,SubFlag,OperatorID,AssignOperator,AssignDate,OperDate,Remark)"); strSql.Append(" values ("); strSql.Append("@DisId,@BatchId,@InCode,@InvoiceNum,@OrderNum,@Mark,@SubFlag,@OperatorID,@AssignOperator,@AssignDate,@OperDate,@Remark)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@DisId", SqlDbType.Int, 4), new SqlParameter("@BatchId", SqlDbType.Int, 4), new SqlParameter("@InCode", SqlDbType.VarChar, 50), new SqlParameter("@InvoiceNum", SqlDbType.VarChar, 50), new SqlParameter("@OrderNum", SqlDbType.VarChar, 50), new SqlParameter("@Mark", SqlDbType.Int, 4), new SqlParameter("@SubFlag", SqlDbType.Int, 4), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@AssignOperator", SqlDbType.VarChar, 50), new SqlParameter("@AssignDate", SqlDbType.DateTime), new SqlParameter("@OperDate", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.VarChar, 200) }; parameters[0].Value = model.DisId; parameters[1].Value = model.BatchId; parameters[2].Value = model.InCode; parameters[3].Value = model.InvoiceNum; parameters[4].Value = model.OrderNum; parameters[5].Value = model.Mark; parameters[6].Value = model.SubFlag; parameters[7].Value = model.OperatorID; parameters[8].Value = model.AssignOperator; parameters[9].Value = model.AssignDate; parameters[10].Value = model.OperDate; parameters[11].Value = model.Remark; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int ID) { WebDemo.BLL.WebDemo.InvoiceNumInfo bll = new WebDemo.BLL.WebDemo.InvoiceNumInfo(); WebDemo.Model.WebDemo.InvoiceNumInfo model = bll.GetModel(ID); this.lblID.Text = model.ID.ToString(); this.lblDisId.Text = model.DisId.ToString(); this.lblBatchId.Text = model.BatchId.ToString(); this.lblInCode.Text = model.InCode; this.lblInvoiceNum.Text = model.InvoiceNum; this.lblOrderNum.Text = model.OrderNum; this.lblMark.Text = model.Mark.ToString(); this.lblSubFlag.Text = model.SubFlag.ToString(); this.lblOperatorID.Text = model.OperatorID.ToString(); this.lblAssignOperator.Text = model.AssignOperator; this.lblAssignDate.Text = model.AssignDate.ToString(); this.lblOperDate.Text = model.OperDate.ToString(); this.lblRemark.Text = model.Remark; }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.InvoiceNumInfo GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,DisId,BatchId,InCode,InvoiceNum,OrderNum,Mark,SubFlag,OperatorID,AssignOperator,AssignDate,OperDate,Remark from InvoiceNumInfo "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; WebDemo.Model.WebDemo.InvoiceNumInfo model = new WebDemo.Model.WebDemo.InvoiceNumInfo(); 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 (!PageValidate.IsNumber(txtDisId.Text)) { strErr += "DisId格式错误!\\n"; } if (!PageValidate.IsNumber(txtBatchId.Text)) { strErr += "BatchId格式错误!\\n"; } if (this.txtInCode.Text.Trim().Length == 0) { strErr += "InCode不能为空!\\n"; } if (this.txtInvoiceNum.Text.Trim().Length == 0) { strErr += "InvoiceNum不能为空!\\n"; } if (this.txtOrderNum.Text.Trim().Length == 0) { strErr += "OrderNum不能为空!\\n"; } if (!PageValidate.IsNumber(txtMark.Text)) { strErr += "Mark格式错误!\\n"; } if (!PageValidate.IsNumber(txtSubFlag.Text)) { strErr += "SubFlag格式错误!\\n"; } if (!PageValidate.IsNumber(txtOperatorID.Text)) { strErr += "OperatorID格式错误!\\n"; } if (this.txtAssignOperator.Text.Trim().Length == 0) { strErr += "AssignOperator不能为空!\\n"; } if (!PageValidate.IsDateTime(txtAssignDate.Text)) { strErr += "AssignDate格式错误!\\n"; } if (!PageValidate.IsDateTime(txtOperDate.Text)) { strErr += "OperDate格式错误!\\n"; } if (this.txtRemark.Text.Trim().Length == 0) { strErr += "Remark不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int DisId = int.Parse(this.txtDisId.Text); int BatchId = int.Parse(this.txtBatchId.Text); string InCode = this.txtInCode.Text; string InvoiceNum = this.txtInvoiceNum.Text; string OrderNum = this.txtOrderNum.Text; int Mark = int.Parse(this.txtMark.Text); int SubFlag = int.Parse(this.txtSubFlag.Text); int OperatorID = int.Parse(this.txtOperatorID.Text); string AssignOperator = this.txtAssignOperator.Text; DateTime AssignDate = DateTime.Parse(this.txtAssignDate.Text); DateTime OperDate = DateTime.Parse(this.txtOperDate.Text); string Remark = this.txtRemark.Text; WebDemo.Model.WebDemo.InvoiceNumInfo model = new WebDemo.Model.WebDemo.InvoiceNumInfo(); model.DisId = DisId; model.BatchId = BatchId; model.InCode = InCode; model.InvoiceNum = InvoiceNum; model.OrderNum = OrderNum; model.Mark = Mark; model.SubFlag = SubFlag; model.OperatorID = OperatorID; model.AssignOperator = AssignOperator; model.AssignDate = AssignDate; model.OperDate = OperDate; model.Remark = Remark; WebDemo.BLL.WebDemo.InvoiceNumInfo bll = new WebDemo.BLL.WebDemo.InvoiceNumInfo(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }