/// <summary> /// 增加一条数据 /// </summary> public bool Add(Bsam.Core.Model.Models.Model.Sfc_Mitem model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Sfc_Mitem("); strSql.Append("Id,MitemCode,MitemName,MitemDesc,MitemType,Brand,Buyer,DutyPerson,SupplierId,DefaultInvId,Uom,DateTimeCreated,UserCreator,DateTimeModified,UserModified,State,OrgId)"); strSql.Append(" values ("); strSql.Append("@Id,@MitemCode,@MitemName,@MitemDesc,@MitemType,@Brand,@Buyer,@DutyPerson,@SupplierId,@DefaultInvId,@Uom,@DateTimeCreated,@UserCreator,@DateTimeModified,@UserModified,@State,@OrgId)"); SQLiteParameter[] parameters = { new SQLiteParameter("@Id", DbType.Int32, 8), new SQLiteParameter("@MitemCode", DbType.String, 0), new SQLiteParameter("@MitemName", DbType.String, 0), new SQLiteParameter("@MitemDesc", DbType.String, 0), new SQLiteParameter("@MitemType", DbType.String, 0), new SQLiteParameter("@Brand", DbType.String, 0), new SQLiteParameter("@Buyer", DbType.String, 0), new SQLiteParameter("@DutyPerson", DbType.String, 0), new SQLiteParameter("@SupplierId", DbType.Int32, 4), new SQLiteParameter("@DefaultInvId", DbType.Int32, 4), new SQLiteParameter("@Uom", DbType.String, 0), new SQLiteParameter("@DateTimeCreated", DbType.Date), new SQLiteParameter("@UserCreator", DbType.String, 0), new SQLiteParameter("@DateTimeModified", DbType.Date), new SQLiteParameter("@UserModified", DbType.String, 0), new SQLiteParameter("@State", DbType.bit, 1), new SQLiteParameter("@OrgId", DbType.String, 0) }; parameters[0].Value = model.Id; parameters[1].Value = model.MitemCode; parameters[2].Value = model.MitemName; parameters[3].Value = model.MitemDesc; parameters[4].Value = model.MitemType; parameters[5].Value = model.Brand; parameters[6].Value = model.Buyer; parameters[7].Value = model.DutyPerson; parameters[8].Value = model.SupplierId; parameters[9].Value = model.DefaultInvId; parameters[10].Value = model.Uom; parameters[11].Value = model.DateTimeCreated; parameters[12].Value = model.UserCreator; parameters[13].Value = model.DateTimeModified; parameters[14].Value = model.UserModified; parameters[15].Value = model.State; parameters[16].Value = model.OrgId; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo() { Bsam.Core.Model.Models.BLL.Sfc_Mitem bll = new Bsam.Core.Model.Models.BLL.Sfc_Mitem(); Bsam.Core.Model.Models.Model.Sfc_Mitem model = bll.GetModel(); this.lblId.Text = model.Id.ToString(); this.lblMitemCode.Text = model.MitemCode; this.lblMitemName.Text = model.MitemName; this.lblMitemDesc.Text = model.MitemDesc; this.lblMitemType.Text = model.MitemType; this.lblBrand.Text = model.Brand; this.lblBuyer.Text = model.Buyer; this.lblDutyPerson.Text = model.DutyPerson; this.lblSupplierId.Text = model.SupplierId.ToString(); this.lblDefaultInvId.Text = model.DefaultInvId.ToString(); this.lblUom.Text = model.Uom; this.lblDateTimeCreated.Text = model.DateTimeCreated.ToString(); this.lblUserCreator.Text = model.UserCreator; this.lblDateTimeModified.Text = model.DateTimeModified.ToString(); this.lblUserModified.Text = model.UserModified; this.lblState.Text = model.State?"是":"否"; this.lblOrgId.Text = model.OrgId; }
private void ShowInfo() { Bsam.Core.Model.Models.BLL.Sfc_Mitem bll = new Bsam.Core.Model.Models.BLL.Sfc_Mitem(); Bsam.Core.Model.Models.Model.Sfc_Mitem model = bll.GetModel(); this.txtId.Text = model.Id.ToString(); this.txtMitemCode.Text = model.MitemCode; this.txtMitemName.Text = model.MitemName; this.txtMitemDesc.Text = model.MitemDesc; this.txtMitemType.Text = model.MitemType; this.txtBrand.Text = model.Brand; this.txtBuyer.Text = model.Buyer; this.txtDutyPerson.Text = model.DutyPerson; this.txtSupplierId.Text = model.SupplierId.ToString(); this.txtDefaultInvId.Text = model.DefaultInvId.ToString(); this.txtUom.Text = model.Uom; this.txtDateTimeCreated.Text = model.DateTimeCreated.ToString(); this.txtUserCreator.Text = model.UserCreator; this.txtDateTimeModified.Text = model.DateTimeModified.ToString(); this.txtUserModified.Text = model.UserModified; this.chkState.Checked = model.State; this.txtOrgId.Text = model.OrgId; }
/// <summary> /// 得到一个对象实体 /// </summary> public Bsam.Core.Model.Models.Model.Sfc_Mitem GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,MitemCode,MitemName,MitemDesc,MitemType,Brand,Buyer,DutyPerson,SupplierId,DefaultInvId,Uom,DateTimeCreated,UserCreator,DateTimeModified,UserModified,State,OrgId from Sfc_Mitem "); strSql.Append(" where "); SQLiteParameter[] parameters = { }; Bsam.Core.Model.Models.Model.Sfc_Mitem model = new Bsam.Core.Model.Models.Model.Sfc_Mitem(); DataSet ds = DbHelperSQLite.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(txtId.Text)) { strErr += "Id格式错误!\\n"; } if (this.txtMitemCode.Text.Trim().Length == 0) { strErr += "MitemCode不能为空!\\n"; } if (this.txtMitemName.Text.Trim().Length == 0) { strErr += "MitemName不能为空!\\n"; } if (this.txtMitemDesc.Text.Trim().Length == 0) { strErr += "MitemDesc不能为空!\\n"; } if (this.txtMitemType.Text.Trim().Length == 0) { strErr += "MitemType不能为空!\\n"; } if (this.txtBrand.Text.Trim().Length == 0) { strErr += "Brand不能为空!\\n"; } if (this.txtBuyer.Text.Trim().Length == 0) { strErr += "Buyer不能为空!\\n"; } if (this.txtDutyPerson.Text.Trim().Length == 0) { strErr += "DutyPerson不能为空!\\n"; } if (!PageValidate.IsNumber(txtSupplierId.Text)) { strErr += "SupplierId格式错误!\\n"; } if (!PageValidate.IsNumber(txtDefaultInvId.Text)) { strErr += "DefaultInvId格式错误!\\n"; } if (this.txtUom.Text.Trim().Length == 0) { strErr += "Uom不能为空!\\n"; } if (!PageValidate.IsDateTime(txtDateTimeCreated.Text)) { strErr += "DateTimeCreated格式错误!\\n"; } if (this.txtUserCreator.Text.Trim().Length == 0) { strErr += "UserCreator不能为空!\\n"; } if (!PageValidate.IsDateTime(txtDateTimeModified.Text)) { strErr += "DateTimeModified格式错误!\\n"; } if (this.txtUserModified.Text.Trim().Length == 0) { strErr += "UserModified不能为空!\\n"; } if (this.txtOrgId.Text.Trim().Length == 0) { strErr += "OrgId不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int Id = int.Parse(this.txtId.Text); string MitemCode = this.txtMitemCode.Text; string MitemName = this.txtMitemName.Text; string MitemDesc = this.txtMitemDesc.Text; string MitemType = this.txtMitemType.Text; string Brand = this.txtBrand.Text; string Buyer = this.txtBuyer.Text; string DutyPerson = this.txtDutyPerson.Text; int SupplierId = int.Parse(this.txtSupplierId.Text); int DefaultInvId = int.Parse(this.txtDefaultInvId.Text); string Uom = this.txtUom.Text; DateTime DateTimeCreated = DateTime.Parse(this.txtDateTimeCreated.Text); string UserCreator = this.txtUserCreator.Text; DateTime DateTimeModified = DateTime.Parse(this.txtDateTimeModified.Text); string UserModified = this.txtUserModified.Text; bool State = this.chkState.Checked; string OrgId = this.txtOrgId.Text; Bsam.Core.Model.Models.Model.Sfc_Mitem model = new Bsam.Core.Model.Models.Model.Sfc_Mitem(); model.Id = Id; model.MitemCode = MitemCode; model.MitemName = MitemName; model.MitemDesc = MitemDesc; model.MitemType = MitemType; model.Brand = Brand; model.Buyer = Buyer; model.DutyPerson = DutyPerson; model.SupplierId = SupplierId; model.DefaultInvId = DefaultInvId; model.Uom = Uom; model.DateTimeCreated = DateTimeCreated; model.UserCreator = UserCreator; model.DateTimeModified = DateTimeModified; model.UserModified = UserModified; model.State = State; model.OrgId = OrgId; Bsam.Core.Model.Models.BLL.Sfc_Mitem bll = new Bsam.Core.Model.Models.BLL.Sfc_Mitem(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Bsam.Core.Model.Models.Model.Sfc_Mitem DataRowToModel(DataRow row) { Bsam.Core.Model.Models.Model.Sfc_Mitem model = new Bsam.Core.Model.Models.Model.Sfc_Mitem(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["MitemCode"] != null) { model.MitemCode = row["MitemCode"].ToString(); } if (row["MitemName"] != null) { model.MitemName = row["MitemName"].ToString(); } if (row["MitemDesc"] != null) { model.MitemDesc = row["MitemDesc"].ToString(); } if (row["MitemType"] != null) { model.MitemType = row["MitemType"].ToString(); } if (row["Brand"] != null) { model.Brand = row["Brand"].ToString(); } if (row["Buyer"] != null) { model.Buyer = row["Buyer"].ToString(); } if (row["DutyPerson"] != null) { model.DutyPerson = row["DutyPerson"].ToString(); } if (row["SupplierId"] != null && row["SupplierId"].ToString() != "") { model.SupplierId = int.Parse(row["SupplierId"].ToString()); } if (row["DefaultInvId"] != null && row["DefaultInvId"].ToString() != "") { model.DefaultInvId = int.Parse(row["DefaultInvId"].ToString()); } if (row["Uom"] != null) { model.Uom = row["Uom"].ToString(); } if (row["DateTimeCreated"] != null && row["DateTimeCreated"].ToString() != "") { model.DateTimeCreated = DateTime.Parse(row["DateTimeCreated"].ToString()); } if (row["UserCreator"] != null) { model.UserCreator = row["UserCreator"].ToString(); } if (row["DateTimeModified"] != null && row["DateTimeModified"].ToString() != "") { model.DateTimeModified = DateTime.Parse(row["DateTimeModified"].ToString()); } if (row["UserModified"] != null) { model.UserModified = row["UserModified"].ToString(); } if (row["State"] != null && row["State"].ToString() != "") { if ((row["State"].ToString() == "1") || (row["State"].ToString().ToLower() == "true")) { model.State = true; } else { model.State = false; } } if (row["OrgId"] != null) { model.OrgId = row["OrgId"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Bsam.Core.Model.Models.Model.Sfc_Mitem model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Sfc_Mitem set "); strSql.Append("Id=@Id,"); strSql.Append("MitemCode=@MitemCode,"); strSql.Append("MitemName=@MitemName,"); strSql.Append("MitemDesc=@MitemDesc,"); strSql.Append("MitemType=@MitemType,"); strSql.Append("Brand=@Brand,"); strSql.Append("Buyer=@Buyer,"); strSql.Append("DutyPerson=@DutyPerson,"); strSql.Append("SupplierId=@SupplierId,"); strSql.Append("DefaultInvId=@DefaultInvId,"); strSql.Append("Uom=@Uom,"); strSql.Append("DateTimeCreated=@DateTimeCreated,"); strSql.Append("UserCreator=@UserCreator,"); strSql.Append("DateTimeModified=@DateTimeModified,"); strSql.Append("UserModified=@UserModified,"); strSql.Append("State=@State,"); strSql.Append("OrgId=@OrgId"); strSql.Append(" where "); SQLiteParameter[] parameters = { new SQLiteParameter("@Id", DbType.Int32, 8), new SQLiteParameter("@MitemCode", DbType.String, 0), new SQLiteParameter("@MitemName", DbType.String, 0), new SQLiteParameter("@MitemDesc", DbType.String, 0), new SQLiteParameter("@MitemType", DbType.String, 0), new SQLiteParameter("@Brand", DbType.String, 0), new SQLiteParameter("@Buyer", DbType.String, 0), new SQLiteParameter("@DutyPerson", DbType.String, 0), new SQLiteParameter("@SupplierId", DbType.Int32, 4), new SQLiteParameter("@DefaultInvId", DbType.Int32, 4), new SQLiteParameter("@Uom", DbType.String, 0), new SQLiteParameter("@DateTimeCreated", DbType.Date), new SQLiteParameter("@UserCreator", DbType.String, 0), new SQLiteParameter("@DateTimeModified", DbType.Date), new SQLiteParameter("@UserModified", DbType.String, 0), new SQLiteParameter("@State", DbType.bit, 1), new SQLiteParameter("@OrgId", DbType.String, 0) }; parameters[0].Value = model.Id; parameters[1].Value = model.MitemCode; parameters[2].Value = model.MitemName; parameters[3].Value = model.MitemDesc; parameters[4].Value = model.MitemType; parameters[5].Value = model.Brand; parameters[6].Value = model.Buyer; parameters[7].Value = model.DutyPerson; parameters[8].Value = model.SupplierId; parameters[9].Value = model.DefaultInvId; parameters[10].Value = model.Uom; parameters[11].Value = model.DateTimeCreated; parameters[12].Value = model.UserCreator; parameters[13].Value = model.DateTimeModified; parameters[14].Value = model.UserModified; parameters[15].Value = model.State; parameters[16].Value = model.OrgId; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }