private void btnCreate_Click(object sender, EventArgs e) { ProductLineInfo target = new ProductLineInfo(); target.Name = txtProductLineName.Text.Trim(); target.SupplierName = (dropSuppliers.SelectedValue.Length > 0) ? dropSuppliers.SelectedValue : null; ValidationResults results = Hishop.Components.Validation.Validation.Validate<ProductLineInfo>(target, new string[] { "ValProductLine" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable<ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } else if (ProductLineHelper.AddProductLine(target)) { Reset(); ShowMsg("成功的添加了一条产品线", true); } else { ShowMsg("添加产品线失败", false); } }
public static bool UpdateProductLine(ProductLineInfo productLine) { Globals.EntityCoding(productLine, true); bool flag = ProductProvider.Instance().UpdateProductLine(productLine); if (flag) { EventLogs.WriteOperationLog(Privilege.EditProductLine, string.Format(CultureInfo.InvariantCulture, "修改了产品线", new object[0])); } return flag; }
public static ProductLineInfo PopulateProductLine(IDataRecord reader) { if (null == reader) { return null; } ProductLineInfo info2 = new ProductLineInfo(); info2.LineId = (int) reader["LineId"]; info2.Name = (string) reader["Name"]; ProductLineInfo info = info2; if (reader["SupplierName"] != DBNull.Value) { info.SupplierName = (string) reader["SupplierName"]; } return info; }
public override IList<ProductLineInfo> GetProductLineList() { IList<ProductLineInfo> list = new List<ProductLineInfo>(); DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_ProductLines"); if (HiContext.Current.User.UserRole == UserRole.Distributor) { sqlStringCommand.CommandText = sqlStringCommand.CommandText + " WHERE LineId IN (SELECT LineId FROM Hishop_DistributorProductLines WHERE UserId = @UserId)"; this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, HiContext.Current.User.UserId); } using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { while (null != reader && reader.Read()) { ProductLineInfo productLineInfo = new ProductLineInfo(); productLineInfo.LineId = (int)reader["LineId"]; productLineInfo.Name = (string)reader["Name"]; ProductLineInfo item = productLineInfo; list.Add(item); } } return list; }
public override bool UpdateProductLine(ProductLineInfo productLine) { DbCommand sqlStringCommand = database.GetSqlStringCommand("UPDATE Hishop_ProductLines SET Name=@Name, SupplierName=@SupplierName WHERE LineId=@LineId"); database.AddInParameter(sqlStringCommand, "Name", DbType.String, productLine.Name); database.AddInParameter(sqlStringCommand, "SupplierName", DbType.String, productLine.SupplierName); database.AddInParameter(sqlStringCommand, "LineId", DbType.Int32, productLine.LineId); return (database.ExecuteNonQuery(sqlStringCommand) == 1); }
public override bool AddProductLine(ProductLineInfo productLine) { DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO Hishop_ProductLines(Name, SupplierName) VALUES(@Name, @SupplierName)"); database.AddInParameter(sqlStringCommand, "Name", DbType.String, productLine.Name); database.AddInParameter(sqlStringCommand, "SupplierName", DbType.String, productLine.SupplierName); return (database.ExecuteNonQuery(sqlStringCommand) == 1); }
public abstract bool AddProductLine(ProductLineInfo productLine);
public abstract bool UpdateProductLine(ProductLineInfo productLine);