/// <summary> /// Додавання позицій в документ по коду одиниці /// </summary> /// <param name="WareCode"></param> /// <returns></returns> private WareDocumentDetail AddDocumenDetailByWareCode(string WareCode) { DocumentDetailsLogic details = new DocumentDetailsLogic(manager); WareCodesLogic wareCodesLogic = new WareCodesLogic(manager); WareDocumentDetail result = null; Ware ware = wareCodesLogic.GetWareByCode(WareCode); if (ware != null) { int wareId = ware.ID; decimal unitQuantity = 1; decimal secondaryUnitQuantity = 0; decimal priceForUnit = 0; decimal discountForUnit = 0; decimal endSalePriceForUnit = 0; decimal endPrice = 0; int currencyId = Convert.ToInt32(CurrencyLUE.EditValue); int priceGroupID = 1; WareDocumentDetail DocumentDetail = new WareDocumentDetail(); //створюємо новий запис в деталізації документа і повертаємо його DocumentDetail = details.CreateWithNoSave(wareId, unitQuantity, secondaryUnitQuantity, priceForUnit, discountForUnit, endSalePriceForUnit, endPrice, currencyId, priceGroupID); documentDetailsView.Add(DocumentDetail); result = DocumentDetail; FillDetails(); } else { MessageBox.Show("Товар з даним кодом не знайдено"); } return(result); }
private void FillCodes() { WareCodesLogic codes = new WareCodesLogic(manager); foreach (var a in codes.GetAll(Convert.ToInt32(id))) { codesList.Add(a.Code); } CodesGV.DataSource = (from c in codesList select new { Code = c }).ToList(); Update(); }
private void SaveBt_Click(object sender, EventArgs e) { WaresLogic wares = new WaresLogic(manager); WareCodesLogic codes = new WareCodesLogic(manager); string name = NameTB.Text; int? categoryId = null; if (CategoriesCB.SelectedIndex > 0) { categoryId = Convert.ToInt32(CategoriesCB.SelectedValue); } int?manufacturerId = null; if (ManufacturersCB.SelectedIndex > 0) { manufacturerId = Convert.ToInt32(ManufacturersCB.SelectedValue); } int unitId = Convert.ToInt32(UnitsCB.SelectedValue); int? secondaryUnitId = null; decimal?secondaryUnitQuantity = null; if (SecondaryUnitsCB.SelectedIndex > 0) { secondaryUnitId = Convert.ToInt32(SecondaryUnitsCB.SelectedValue); secondaryUnitQuantity = Convert.ToDecimal(SecondaryQuantityNUD.Value); } Model.Ware ware = null; if (mode == "new") { ware = wares.Create(NameTB.Text, unitId, 0, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity); } if (mode == "edit") { ware = wares.Update(Convert.ToInt32(id), NameTB.Text, unitId, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity); foreach (string code in codesListForDelete) { codes.Delete(Convert.ToInt32(id), code); } } foreach (string code in codesList) { codes.Create(ware, code); } manager.Save(); this.Close(); }
/// <summary> /// Додавання позицій в документ по коду одиниці /// </summary> /// <param name="WareCode"></param> /// <returns></returns> private WareDocumentDetail AddDocumenDetailByWareCode(string WareCode) { DocumentDetailsLogic details = new DocumentDetailsLogic(manager); WareCodesLogic wareCodesLogic = new WareCodesLogic(manager); WareDocumentDetail result = null; Ware ware = wareCodesLogic.GetWareByCode(WareCode); if (ware != null) { int wareId = ware.ID; decimal unitQuantity = 1; decimal secondaryUnitQuantity = 0; decimal priceForUnit = 0; decimal discountForUnit = 0; decimal endSalePriceForUnit = 0; decimal endPrice = 0; int currencyId = Convert.ToInt32(CurrencyLUE.EditValue); int priceGroupID = 1; WareDocumentDetail DocumentDetail = new WareDocumentDetail(); //створюємо новий запис в деталізації документа і повертаємо його DocumentDetail = details.CreateWithNoSave(wareId, unitQuantity, secondaryUnitQuantity, priceForUnit, discountForUnit, endSalePriceForUnit, endPrice, currencyId, priceGroupID); documentDetailsView.Add(DocumentDetail); result = DocumentDetail; FillDetails(); } else { MessageBox.Show("Товар з даним кодом не знайдено"); } return result; }
private void SaveBt_Click(object sender, EventArgs e) { WareCodesLogic codes = new WareCodesLogic(manager); codes.Create(ware, CodeTB.Text); }
private void SaveBt_Click(object sender, EventArgs e) { WaresLogic wares = new WaresLogic(manager); WareCodesLogic codes = new WareCodesLogic(manager); string name = NameTB.Text; int? categoryId = null; if (CategoriesCB.SelectedIndex > 0) { categoryId = Convert.ToInt32(CategoriesCB.SelectedValue); } int?manufacturerId = null; if (ManufacturersCB.SelectedIndex > 0) { manufacturerId = Convert.ToInt32(ManufacturersCB.SelectedValue); } int unitId = Convert.ToInt32(UnitsCB.SelectedValue); int? secondaryUnitId = null; decimal?secondaryUnitQuantity = null; decimal timeLimit = 0; timeLimit = TimeLimitNUD.Value; if (SecondaryUnitsCB.SelectedIndex > 0) { secondaryUnitId = Convert.ToInt32(SecondaryUnitsCB.SelectedValue); secondaryUnitQuantity = Convert.ToDecimal(SecondaryQuantityNUD.Value); } Model.Ware ware = null; //зберігаємо код якщо він введений в текстове поле, а інших кодів немає if ((codesList.Count == 0) & (CodeTB.Text.Trim().Length > 0)) { codesList.Add(CodeTB.Text.Trim()); codesListForDelete.Remove(CodeTB.Text.Trim()); } if (mode == "new") { if (openFileDialog1.CheckPathExists == true) { image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName); } ware = wares.Create(NameTB.Text, unitId, 0, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image); } if (mode == "edit") { if (_image != null) { image = Helpers.ImageOperations.ImageToByteArray(_image); } else { image = null; } ware = wares.Update(Convert.ToInt32(id), NameTB.Text, unitId, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image); foreach (string code in codesListForDelete) { codes.Delete(Convert.ToInt32(id), code); } } foreach (string code in codesList) { if (codes.CodeForOtherWareExists(id, code) == false) { codes.Create(ware, code); } else { MessageBox.Show("Введений код " + code + " вже існує і не був збережений"); } } WareTimeLimitsLogic timeLimits = new WareTimeLimitsLogic(manager); timeLimits.Create(ware, Convert.ToDecimal(TimeLimitNUD.Value), true); manager.Save(); if (AddComponentsCB.Checked == true) { Wares.Ware.WareComponentData form = new Wares.Ware.WareComponentData("edit", Convert.ToInt32(ware.ID)); form.ShowDialog(); } this.Close(); }
private void SaveBt_Click(object sender, EventArgs e) { WaresLogic wares = new WaresLogic(manager); WareCodesLogic codes = new WareCodesLogic(manager); string name = NameTB.Text; int? categoryId = null; if (CategoriesCB.SelectedIndex > 0) categoryId = Convert.ToInt32(CategoriesCB.SelectedValue); int? manufacturerId = null; if (ManufacturersCB.SelectedIndex > 0) manufacturerId = Convert.ToInt32(ManufacturersCB.SelectedValue); int unitId = Convert.ToInt32(UnitsCB.SelectedValue); int? secondaryUnitId = null; decimal? secondaryUnitQuantity = null; decimal timeLimit = 0; timeLimit = TimeLimitNUD.Value; if (SecondaryUnitsCB.SelectedIndex > 0) { secondaryUnitId = Convert.ToInt32(SecondaryUnitsCB.SelectedValue); secondaryUnitQuantity = Convert.ToDecimal(SecondaryQuantityNUD.Value); } Model.Ware ware = null; //зберігаємо код якщо він введений в текстове поле, а інших кодів немає if ((codesList.Count == 0) & (CodeTB.Text.Trim().Length > 0)) { codesList.Add(CodeTB.Text.Trim()); codesListForDelete.Remove(CodeTB.Text.Trim()); } if (mode == "new") { if (openFileDialog1.CheckPathExists == true) image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName); ware = wares.Create(NameTB.Text, unitId, 0, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity,image); } if (mode == "edit") { if (_image != null) image = Helpers.ImageOperations.ImageToByteArray(_image); else image = null; ware = wares.Update(Convert.ToInt32(id), NameTB.Text, unitId, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image); foreach (string code in codesListForDelete) { codes.Delete(Convert.ToInt32(id), code); } } foreach (string code in codesList) { if (codes.CodeForOtherWareExists(id, code) == false) codes.Create(ware, code); else MessageBox.Show("Введений код " + code + " вже існує і не був збережений"); } WareTimeLimitsLogic timeLimits = new WareTimeLimitsLogic(manager); timeLimits.Create(ware, Convert.ToDecimal(TimeLimitNUD.Value), true); manager.Save(); if (AddComponentsCB.Checked == true) { Wares.Ware.WareComponentData form = new Wares.Ware.WareComponentData("edit", Convert.ToInt32(ware.ID)); form.ShowDialog(); } this.Close(); }
private void FillCodes() { WareCodesLogic codes = new WareCodesLogic(manager); foreach (var a in codes.GetAll(Convert.ToInt32(id))) { codesList.Add(a.Code); } CodesGV.DataSource = (from c in codesList select new { Code = c }).ToList(); Update(); }
private void SaveBt_Click(object sender, EventArgs e) { WareCodesLogic codes = new WareCodesLogic(manager); codes.Create(ware, CodeTB.Text); }