// Save , Edit and Delete Part protected void Save_Click(object sender, EventArgs e) { ListPrice listPrice = ListPriceModel(); if (listPrice.Id == 0) { try { db.ListPrice.Add(listPrice); db.SaveChanges(); } catch (Exception except) { } } else { try { db.ListPrice.AddOrUpdate(listPrice); db.SaveChanges(); } catch (Exception except) { } } ClearModel(); Page.Response.Redirect(Page.Request.Url.ToString(), true); }
public async Task <IActionResult> delete(ListPrice listPrice) { try { List <PriceList> list = listPrice.prices; for (int i = 0; i < list.Count; i++) { var price = _context.PriceList.Where(x => x.ItemId == list[i].ItemId).First(); _context.PriceList.Remove(price); _context.SaveChanges(); } return(StatusCode(200, new { status = "200", delete = true, message = "Deleted successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", delete = false, message = ex.ToString() })); } }
public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + (Class == null ? 0 : Class.GetHashCode()); hash = hash * 23 + (Color == null ? 0 : Color.GetHashCode()); hash = hash * 23 + (DaysToManufacture == default(int) ? 0 : DaysToManufacture.GetHashCode()); hash = hash * 23 + (DiscontinuedDate == null ? 0 : DiscontinuedDate.GetHashCode()); hash = hash * 23 + (FinishedGoodsFlag == default(bool) ? 0 : FinishedGoodsFlag.GetHashCode()); hash = hash * 23 + (ListPrice == default(decimal) ? 0 : ListPrice.GetHashCode()); hash = hash * 23 + (MakeFlag == default(bool) ? 0 : MakeFlag.GetHashCode()); hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode()); hash = hash * 23 + (Name == null ? 0 : Name.GetHashCode()); hash = hash * 23 + (ProductLine == null ? 0 : ProductLine.GetHashCode()); hash = hash * 23 + (ProductModelId == null ? 0 : ProductModelId.GetHashCode()); hash = hash * 23 + (ProductNumber == null ? 0 : ProductNumber.GetHashCode()); hash = hash * 23 + (ProductSubcategoryId == null ? 0 : ProductSubcategoryId.GetHashCode()); hash = hash * 23 + (ReorderPoint == default(short) ? 0 : ReorderPoint.GetHashCode()); hash = hash * 23 + (Rowguid == default(Guid) ? 0 : Rowguid.GetHashCode()); hash = hash * 23 + (SafetyStockLevel == default(short) ? 0 : SafetyStockLevel.GetHashCode()); hash = hash * 23 + (SellEndDate == null ? 0 : SellEndDate.GetHashCode()); hash = hash * 23 + (SellStartDate == default(DateTime) ? 0 : SellStartDate.GetHashCode()); hash = hash * 23 + (Size == null ? 0 : Size.GetHashCode()); hash = hash * 23 + (SizeUnitMeasureCode == null ? 0 : SizeUnitMeasureCode.GetHashCode()); hash = hash * 23 + (StandardCost == default(decimal) ? 0 : StandardCost.GetHashCode()); hash = hash * 23 + (Style == null ? 0 : Style.GetHashCode()); hash = hash * 23 + (Weight == null ? 0 : Weight.GetHashCode()); hash = hash * 23 + (WeightUnitMeasureCode == null ? 0 : WeightUnitMeasureCode.GetHashCode()); return(hash); } }
public ProductValidator(IProductService productService) { _productService = productService; RuleFor(x => x.Name).Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty().MaximumLength(50) .Must(IsUniqueProductName).WithMessage("A product with that name already exists."); RuleFor(x => x.ProductNumber).Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty().WithMessage("Product Number is required.") .MaximumLength(25).WithMessage("Product Number must be 1-25 characters long.") .Must(IsUniqueProductNumber).WithMessage("A product with that number already exists"); RuleFor(x => x.Color).Cascade(CascadeMode.StopOnFirstFailure) .MaximumLength(15); RuleFor(x => x.ListPrice).Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty().WithMessage("List Price is required.") .Must(ListPrice => PriceMustBeACurrency(ListPrice.ToString())) .WithMessage("List price may include only numbers, commas, and decimals.") .Must(ListPrice => PriceMustBeGreaterThanZero(ListPrice.ToString())) .WithMessage("List price must be greater than 0."); //RuleFor(x => x.SellStartDate).Cascade(CascadeMode.StopOnFirstFailure) // .NotEmpty().WithMessage("Sell Start Date is required.") // .GreaterThanOrEqualTo(DateTime.Today).WithMessage("Date must be today or later."); }
protected void edit_Command(object sender, CommandEventArgs e) { ListPrice temListPrice = new ListPrice(); int index = Convert.ToInt32(e.CommandArgument); if (SearchListPrice.Count > 0) { temListPrice = SearchListPrice[index]; } else { temListPrice = ListPrice[index]; } try { IdHid.Value = temListPrice.Id.ToString(); PriceTxt.Text = temListPrice.Price.ToString(); AddRegionFromListhtml.SelectedValue = temListPrice.RegionFromId.ToString(); AddRegionToListhtml.SelectedValue = temListPrice.RegionToId.ToString(); AddSupplierListhtml.SelectedValue = temListPrice.SubAccId.ToString(); TransportProductTypeDrop.SelectedValue = temListPrice.ProductType.ToString(); // TransportProductTypeDrop.SelectedValue=temListPrice. } catch (Exception Exec) { } SearchListPrice = new List <ListPrice>(); UpdatePanel3.Update(); }
protected ListPrice SearchModel() { ListPrice listPrice = new ListPrice(); if (PriceTxt.Text != "") { listPrice.Price = Convert.ToInt32(PriceTxt.Text); } if (RegionFromSearchListtxt.SelectedValue != "0") { listPrice.RegionFromId = Convert.ToInt32(RegionFromSearchListtxt.SelectedValue); } if (RegionToSearchListtxt.SelectedValue != "0") { listPrice.RegionToId = Convert.ToInt32(RegionToSearchListtxt.SelectedValue); } if (SupplierSearchListtxt.SelectedValue != "0") { listPrice.SubAccId = Convert.ToInt32(SupplierSearchListtxt.SelectedValue); } return(listPrice); }
protected ListPrice ListPriceModel() { ListPrice listPrice = new ListPrice(); if (IdHid.Value != "0") { listPrice.Id = Convert.ToInt32(IdHid.Value); } if (PriceTxt.Text != "") { listPrice.Price = Convert.ToInt32(PriceTxt.Text); } if (SelectedFromRegionId != "") { listPrice.RegionFromId = Convert.ToInt32(SelectedFromRegionId); } if (SelectedToRegionId != "") { listPrice.RegionToId = Convert.ToInt32(SelectedToRegionId); } if (SelectedSubAccountId != "") { listPrice.SubAccId = Convert.ToInt32(SelectedSubAccountId); } if (ProductType != "") { listPrice.ProductType = Convert.ToInt32(ProductType); } listPrice.LoginID = ExtendedMethod.LoginedUser.Id; return(listPrice); }
public decimal GetDecimalNumberFromListPrice() { if (ListPrice != null) { return(decimal.Parse(ListPrice.Replace("$", ""))); } return(default);
protected void NewSearch_Click(object sender, EventArgs e) { SearchListPrice = new List <ListPrice>(); ClearSearchModel(); myListPrice = new ListPrice(); ListPrice = new List <ListPrice>(); ListPrice = db.ListPrice.ToList(); BindGridList(); }
/// <summary> /// Convert current product price to other currency using currency exchange rate /// </summary> /// <param name="currency"></param> /// <returns></returns> public ProductPrice ConvertTo(Currency currency) { var retVal = new ProductPrice(currency); retVal.ListPrice = ListPrice.ConvertTo(currency); retVal.SalePrice = SalePrice.ConvertTo(currency); retVal.DiscountAmount = DiscountAmount.ConvertTo(currency); retVal.ProductId = ProductId; return(retVal); }
public override object Clone() { var result = MemberwiseClone() as ProductPrice; result.Currency = Currency?.Clone() as Currency; result.DiscountAmount = DiscountAmount?.Clone() as Money; result.ListPrice = ListPrice?.Clone() as Money; result.SalePrice = SalePrice?.Clone() as Money; result.TierPrices = TierPrices?.Select(x => x.Clone() as TierPrice).ToList(); result.Discounts = Discounts?.Select(x => x.Clone() as Discount).ToList(); return(result); }
public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + (EndDate == null ? 0 : EndDate.GetHashCode()); hash = hash * 23 + (ListPrice == default(decimal) ? 0 : ListPrice.GetHashCode()); hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode()); hash = hash * 23 + (ProductId == default(int) ? 0 : ProductId.GetHashCode()); hash = hash * 23 + (StartDate == default(DateTime) ? 0 : StartDate.GetHashCode()); return(hash); } }
// Sarch Part protected void Search_Click(object sender, EventArgs e) { ListPrice = new List <ListPrice>(); myListPrice = new ListPrice(); myListPrice = SearchModel(); var RegionFromId = new SqlParameter(); var RegionToId = new SqlParameter(); var SubAccId = new SqlParameter(); // if (myListPrice.RegionFromId != null) { RegionFromId = new SqlParameter("@RegionFromId", myListPrice.RegionFromId); } else { RegionFromId = new SqlParameter("@RegionFromId", DBNull.Value); } // if (myListPrice.RegionToId != null) { RegionToId = new SqlParameter("@RegionToId", myListPrice.RegionToId); } else { RegionToId = new SqlParameter("@RegionToId", DBNull.Value); } // if (myListPrice.SubAccId != null) { SubAccId = new SqlParameter("@SubAccId", myListPrice.SubAccId); } else { SubAccId = new SqlParameter("@SubAccId", DBNull.Value); } ListPrice = db.Database .SqlQuery <ListPrice>("SP_ListPrice @RegionFromId , @RegionToId , @SubAccId", RegionFromId, RegionToId, SubAccId).ToList(); foreach (var item in ListPrice) { item.FromRegion = db.FromRegion.Where(c => c.Id == item.RegionFromId).FirstOrDefault(); item.FromRegion1 = db.FromRegion.Where(c => c.Id == item.RegionToId).FirstOrDefault(); item.SubAccount = db.SubAccount.Where(c => c.ID == item.SubAccId).FirstOrDefault(); } SearchListPrice = ListPrice; BindGridList(); ClearSearchModel(); }
protected void AddVendorListhtml_SelectedIndexChanged(object sender, EventArgs e) { GetTransportPrice(); Quantity.Text = "5678909876"; ListPrice _ListPrice = db.ListPrice.ToList().FirstOrDefault(o => o.SubAccId == int.Parse(AddVendorListhtml.SelectedValue)); AddFromRegionListhtml.SelectedValue = _ListPrice.RegionFromId.ToString(); AddRegionToListhtml.SelectedValue = _ListPrice.RegionToId.ToString(); TransportPrice.Text = _ListPrice.Price.ToString(); AddTransportTypeListhtml.SelectedValue = _ListPrice.ProductType.ToString(); }
public async Task <IActionResult> create(ListPrice listPrice) { try { List <PriceList> list = listPrice.prices; for (int i = 0; i < list.Count; i++) { PriceList price = new PriceList(); price.ItemId = list[i].ItemId; price.SalesPrice = list[i].SalesPrice; price.Currency = list[i].Currency; _context.Add(price); bool discExist = false; discExist = _context.PriceList.Any(c => c.ItemId == price.ItemId); if (discExist == false) { _context.SaveChanges(); } else { return(StatusCode(404, new { status = "404", create = false, message = "Cannot create a record, item number already exist." })); } } return(StatusCode(200, new { status = "200", create = true, message = "Created successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", create = false, message = ex.ToString() })); } }
public async Task <IActionResult> update(ListPrice listPrice) { try { List <PriceList> list = listPrice.prices; for (int i = 0; i < list.Count; i++) { bool discExist = false; discExist = _context.PriceList.Any(c => c.ItemId == list[i].ItemId); if (discExist == true) { var price = _context.PriceList.Where(x => x.ItemId == list[i].ItemId).First(); price.SalesPrice = list[i].SalesPrice; price.Currency = list[i].Currency; _context.PriceList.Update(price); _context.SaveChanges(); } else { return(StatusCode(404, new { status = "404", update = false, message = "Item number not found." })); } } return(StatusCode(200, new { status = "200", update = true, message = "updated successfully!" })); } catch (Exception ex) { return(StatusCode(500, new { status = "500", update = false, message = ex.ToString() })); } }
/// <summary> /// Convert current product price to other currency using currency exchange rate /// </summary> /// <param name="currency"></param> /// <returns></returns> public ProductPrice ConvertTo(Currency currency) { var retVal = new ProductPrice(currency); retVal.ListPrice = ListPrice.ConvertTo(currency); retVal.SalePrice = SalePrice.ConvertTo(currency); retVal.ProductId = ProductId; if (ActiveDiscount != null) { retVal.ActiveDiscount = ActiveDiscount.ConvertTo(currency); } if (PotentialDiscount != null) { retVal.PotentialDiscount = PotentialDiscount.ConvertTo(currency); } return(retVal); }
public override object Clone() { var result = (ConfiguredGroup)base.Clone(); result.ListPrice = ListPrice?.Clone() as Money; result.SalePrice = SalePrice?.Clone() as Money; result.ListPriceWithTax = ListPriceWithTax?.Clone() as Money; result.SalePriceWithTax = SalePriceWithTax?.Clone() as Money; result.PlacedPrice = PlacedPrice?.Clone() as Money; result.PlacedPriceWithTax = PlacedPriceWithTax?.Clone() as Money; result.ExtendedPrice = ExtendedPrice?.Clone() as Money; result.ExtendedPriceWithTax = ExtendedPriceWithTax?.Clone() as Money; result.TaxTotal = TaxTotal?.Clone() as Money; result.Items = new List <LineItem>(); return(result); }
protected void GetTransportPrice() { int FromReg = Convert.ToInt32(AddFromRegionListhtml.SelectedValue); int ToReg = Convert.ToInt32(AddRegionToListhtml.SelectedValue); int vendor = Convert.ToInt32(AddVendorListhtml.SelectedValue); ListPrice LPrice = db.ListPrice.Where(lP => lP.RegionFromId == FromReg && lP.RegionToId == ToReg && lP.SubAccId == vendor).FirstOrDefault(); if (LPrice != null) { TransportPrice.Text = LPrice.Price.ToString(); } else { TransportPrice.Text = "0"; } // get all Total Again GetTotalTransportPrice(); }
public override object Clone() { var result = base.Clone() as LineItem; result.ListPrice = ListPrice?.Clone() as Money; result.SalePrice = SalePrice?.Clone() as Money; result.DiscountAmount = DiscountAmount?.Clone() as Money; result.DiscountAmountWithTax = DiscountAmountWithTax?.Clone() as Money; result.DiscountTotal = DiscountTotal?.Clone() as Money; result.DiscountTotalWithTax = DiscountTotalWithTax?.Clone() as Money; result.ListPriceWithTax = ListPriceWithTax?.Clone() as Money; result.SalePriceWithTax = SalePriceWithTax?.Clone() as Money; result.PlacedPrice = PlacedPrice?.Clone() as Money; result.PlacedPriceWithTax = PlacedPriceWithTax?.Clone() as Money; result.ExtendedPrice = ExtendedPrice?.Clone() as Money; result.ExtendedPriceWithTax = ExtendedPriceWithTax?.Clone() as Money; result.TaxTotal = TaxTotal?.Clone() as Money; if (Discounts != null) { result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount)); } if (TaxDetails != null) { result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail)); } if (DynamicProperties != null) { result.DynamicProperties = new MutablePagedList <DynamicProperty>(DynamicProperties.Select(x => x.Clone() as DynamicProperty)); } if (ValidationErrors != null) { result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError)); } return(result); }
/// <summary> /// Returns true if Product instances are equal /// </summary> /// <param name="other">Instance of Product to be compared</param> /// <returns>Boolean</returns> public bool Equals(Product other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ProductId == other.ProductId || ProductId != null && ProductId.Equals(other.ProductId) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( ProductNumber == other.ProductNumber || ProductNumber != null && ProductNumber.Equals(other.ProductNumber) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( StandardCost == other.StandardCost || StandardCost != null && StandardCost.Equals(other.StandardCost) ) && ( ListPrice == other.ListPrice || ListPrice != null && ListPrice.Equals(other.ListPrice) ) && ( Size == other.Size || Size != null && Size.Equals(other.Size) ) && ( Weight == other.Weight || Weight != null && Weight.Equals(other.Weight) ) && ( ProductLine == other.ProductLine || ProductLine != null && ProductLine.Equals(other.ProductLine) ) && ( Class == other.Class || Class != null && Class.Equals(other.Class) ) && ( Style == other.Style || Style != null && Style.Equals(other.Style) ) && ( SubCategory == other.SubCategory || SubCategory != null && SubCategory.Equals(other.SubCategory) ) && ( Model == other.Model || Model != null && Model.Equals(other.Model) ) && ( Photo == other.Photo || Photo != null && Photo.Equals(other.Photo) ) && ( Review == other.Review || Review != null && Review.SequenceEqual(other.Review) )); }
/// <summary> /// 开具发票,打印 /// </summary> public void Print() { //没有初始化,不予执行 if (!IsInit) { return; } this.State = State.Start; Log.Debug("开始开具发票"); Log.Debug("InfoClientName(开票名称)-" + InfoClientName + ",InfoClientAddressPhone(开票地址,电话)-" + InfoClientAddressPhone + ",InfoTaxRate(税率)-" + InfoTaxRate + ",ListGoodsName(服务名称)-" + ListGoodsName + ",ListAmount(金额)-" + ListAmount + ",ListPrice(单价)-" + ListPrice + ",ListUnit(单位)-" + ListUnit + ",ListNumber(数量)-" + ListNumber + ",InfoCashier(收款人)-" + InfoCashier + ",InfoChecker(复核人)-" + InfoChecker + ",InfoNotes(备注)-" + InfoNotes); obj.InvInfoInit(); //增值税普通发票 obj.InfoKind = 2; //开票名称 obj.InfoClientName = InfoClientName; //售方地址及电话 obj.InfoSellerAddressPhone = InfoSellerAddressPhone; //售方开户行及账号 obj.InfoSellerBankAccount = InfoSellerBankAccount; //开票地址,电话 obj.InfoClientAddressPhone = InfoClientAddressPhone; //税率 obj.InfoTaxRate = InfoTaxRate; char[] c = new char[] { '|' }; //服务名称 string[] names = ListGoodsName.Split(c); //金额 //string[] amounts = ListAmount.Split(c); string[] prices = ListPrice.Split(c); //单位 string[] units = ListUnit.Split(c); //数量 string[] numbers = ListNumber.Split(c); //含税价标志 string[] pricekind = ListPriceKind.Split(c); obj.ClearInvList(); for (int i = 0; i < names.Length; i++) { if (names[i].Equals("滞纳金") && double.Parse(prices[i]) <= 0) { continue; } //设置开票内容 obj.InvListInit(); //服务名称 obj.ListGoodsName = names[i]; //double amount = double.Parse(amounts[i]) / (InfoTaxRate *0.01 + 1); //obj.ListAmount = Math.Round(amount, 2); //obj.ListTaxAmount = amount * InfoTaxRate * 0.01; //double price = double.Parse(prices[i]) / (InfoTaxRate * 0.01 + 1); obj.ListPrice = double.Parse(prices[i]); obj.ListUnit = units[i]; obj.ListNumber = double.Parse(numbers[i]); obj.ListPriceKind = Int32.Parse(pricekind[i]); obj.AddInvList(); } //收款人 obj.InfoCashier = InfoCashier; //复核人 obj.InfoChecker = InfoChecker; //开票人 obj.InfoInvoicer = InfoChecker; //备注 obj.InfoNotes = InfoNotes; obj.Invoice(); if (obj.RetCode != 4011) { Log.Debug("开具发票失败-" + obj.RetCode + obj.RegMsg); MessageBox.Show(obj.RetMsg); } else { Log.Debug("开具发票成功-开始打印"); //打印 obj.PrintInv(); State = State.End; OnCompleted(null); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (ProductId != null) { hashCode = hashCode * 59 + ProductId.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (ProductNumber != null) { hashCode = hashCode * 59 + ProductNumber.GetHashCode(); } if (Color != null) { hashCode = hashCode * 59 + Color.GetHashCode(); } if (StandardCost != null) { hashCode = hashCode * 59 + StandardCost.GetHashCode(); } if (ListPrice != null) { hashCode = hashCode * 59 + ListPrice.GetHashCode(); } if (Size != null) { hashCode = hashCode * 59 + Size.GetHashCode(); } if (Weight != null) { hashCode = hashCode * 59 + Weight.GetHashCode(); } if (ProductLine != null) { hashCode = hashCode * 59 + ProductLine.GetHashCode(); } if (Class != null) { hashCode = hashCode * 59 + Class.GetHashCode(); } if (Style != null) { hashCode = hashCode * 59 + Style.GetHashCode(); } if (SubCategory != null) { hashCode = hashCode * 59 + SubCategory.GetHashCode(); } if (Model != null) { hashCode = hashCode * 59 + Model.GetHashCode(); } if (Photo != null) { hashCode = hashCode * 59 + Photo.GetHashCode(); } if (Review != null) { hashCode = hashCode * 59 + Review.GetHashCode(); } return(hashCode); } }