private void AddDocumentRowButton_Click(object sender, EventArgs e) { double quantity = double.Parse(quantityET.Text); var productID = productTreeListLookUpEdit.EditValue.ToString(); var lotID = lotTreeListLookUpEdit.EditValue.ToString(); using (var db = new WereDesktopEntities()) { var lots = db.Lot.Where(l => l.ID == lotID).ToList(); foreach (Lot lot in lots) { DocumentRow dr = new DocumentRow(); Guid id = Guid.NewGuid(); dr.ID = id.ToString(); dr.ProductID = productID; dr.LotID = lotID; dr.Quantity = quantity; dr.Sum = Convert.ToDecimal(quantity) * lot.Product.Price; dr.DocumentID = DocumentID; lot.Quantity = lot.Quantity - quantity; db.DocumentRow.AddOrUpdate(dr); db.Lot.AddOrUpdate(lot); db.SaveChanges(); this.Close(); } } }
private void addDocumentButton_Click(object sender, EventArgs e) { try { decimal input = decimal.Parse(inCashET.Text); if (input >= sum) { using (var db = new WereDesktopEntities()) { Document document = new Document(); Guid id = Guid.NewGuid(); document.ID = id.ToString(); document.SourceID = SelectedContragent.SourceContragentID; document.DestinationID = SelectedContragent.contragent.ID; document.DocumentNumber = GenerateDocumentNumber.generateDocumentNumber(); document.Date = DateTime.Now; db.Document.AddOrUpdate(document); db.SaveChanges(); foreach (DocumentRowCart dr in documentRowsList) { DocumentRow docRow = new DocumentRow(); docRow.ID = dr.ID; docRow.ProductID = dr.ProductID; docRow.LotID = dr.LotID; docRow.Quantity = dr.Quantity; docRow.Sum = dr.Sum; docRow.DocumentID = document.ID; db.DocumentRow.Add(docRow); db.SaveChanges(); } DocumentPayment dp = new DocumentPayment(); id = Guid.NewGuid(); dp.ID = id.ToString(); dp.DocumentId = document.ID; dp.MethodOfPayment = "cash"; dp.Price = sum; db.DocumentPayment.Add(dp); db.SaveChanges(); this.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void RegisterCustomer(CreateDocumentDTO dto) { uow.Begin(); var documentRow = new DocumentRow(dto.DocumentRow_AccountNumber, dto.DocumentRow_Description, dto.DocumentRow_Amount); var document = new Document(dto.InsertDateTime, dto.documentNumber, documentRow); try { documentRepository.Save(document); uow.Commit(); } catch (System.Exception ex) { uow.Rollback(); } }
public void Handle(RegisterDocumentCommand command) { uow.Begin(); var documentRow = new DocumentRow(command.DocumentRow_AccountNumber, command.DocumentRow_Description, command.DocumentRow_Amount); var document = new Document(command.InsertDateTime, command.documentNumber, documentRow); try { documentRepository.Save(document); uow.Commit(); } catch (System.Exception ex) { uow.Rollback(); } }
private void addDocumentToDatabaseToBankAccount(List <Classes.DocumentRowCart> list, decimal sum) { using (var db = new WereDesktopEntities()) { Document document = new Document(); Guid id = Guid.NewGuid(); document.ID = id.ToString(); document.SourceID = SelectedContragent.SourceContragentID; document.DestinationID = SelectedContragent.contragent.ID; document.DocumentNumber = GenerateDocumentNumber.generateDocumentNumber(); document.Date = DateTime.Now; db.Document.AddOrUpdate(document); db.SaveChanges(); foreach (DocumentRowCart dr in list) { DocumentRow docRow = new DocumentRow(); docRow.ID = dr.ID; docRow.ProductID = dr.ProductID; docRow.LotID = dr.LotID; docRow.Quantity = dr.Quantity; docRow.Sum = dr.Sum; docRow.DocumentID = document.ID; db.DocumentRow.Add(docRow); db.SaveChanges(); } DocumentPayment dp = new DocumentPayment(); id = Guid.NewGuid(); dp.ID = id.ToString(); dp.DocumentId = document.ID; dp.MethodOfPayment = "bank account"; dp.Price = sum; db.DocumentPayment.Add(dp); db.SaveChanges(); } }
private static object GetValueFromRow <T>(Document tabularData, DocumentRow row, FieldMapping fieldMap, MemberInfo memberInfo) { var stringData = tabularData.HaveHeader ? row[fieldMap.SourceColumnName] : row[fieldMap.SourceColumnNumber]; if (memberInfo is PropertyInfo) { return(ValueFromString(memberInfo as PropertyInfo, stringData)); } if (memberInfo is FieldInfo) { return(ValueFromString(memberInfo as FieldInfo, stringData)); } if (memberInfo is MethodInfo) { return(ValueFromString(memberInfo as MethodInfo, stringData)); } return(null); }
public static string AddRow(DocumentRow Row) { dynamic docs = connection1c.Документы.ИнвентаризацияТоваровНаСкладе; dynamic comDocument = docs.НайтиПоНомеру(Row.Document.Number, Row.Document.Date); dynamic uid = connection1c.NewObject("УникальныйИдентификатор", (comDocument.УникальныйИдентификатор())); dynamic comDocJbj = docs.ПолучитьСсылку(uid).ПолучитьОбъект(); dynamic ware = GetWare(Row.Barcode); if (ware == null) { return("Ошибка: не была найдена номенклатура"); } if (AddRow(ware)) { return(ware.Код); } return("Ошибка: не удалось добавить номенклатуру"); }
public EditDocumentRowForm(DocumentRow row) { InitializeComponent(); this.documentId = row.DocumentID; this.selectedRow = row; this.originalLotId = row.LotID; using (var db = new WereDesktopEntities()) { editDocumentRowProductTreeListLookUpEdit.Properties.DataSource = db.Product.ToList(); editDocumentRowProductTreeListLookUpEdit.EditValue = row.ProductID; editDocumentRowLotTreeListLookUpEdit.Properties.DataSource = db.Lot.Where(l => l.ProductID == row.ProductID).ToList(); editDocumentRowLotTreeListLookUpEdit.EditValue = row.LotID; editDocumentRowQuantityTE.Text = row.Quantity.ToString(); var lots = db.Lot.Where(l => l.ID == row.LotID).ToList(); foreach (Lot lot in lots) { originalLot = lot; } originalQuantity = row.Quantity; } CheckUserInput(); }
private static DocumentRow ExtractHeaderInformation(XmlNode childNode, Document document) { var docRow = new DocumentRow(document); foreach (XmlNode xmlNode in childNode.ChildNodes) { if (xmlNode.Attributes != null && xmlNode.Attributes.Count > 0) { var nameAttrib = xmlNode.Attributes.GetNamedItem("NAME"); if (nameAttrib.IsNull()) nameAttrib = xmlNode.Attributes.GetNamedItem("name"); if (nameAttrib.IsNull()) nameAttrib = xmlNode.Attributes.GetNamedItem("Name"); if (nameAttrib != null) { docRow.Add(nameAttrib.InnerText); } else { docRow.Add(GetNameFromNode(xmlNode)); } } else docRow.Add(GetNameFromNode(xmlNode)); } return docRow; }
private static DocumentRow GetRow(XmlNode childNode, Document document) { var docRow = new DocumentRow(document); foreach (XmlNode xmlNode in childNode.ChildNodes) { docRow.Add(xmlNode.InnerText); } return docRow; }
// POST api/docuemntrow JToken json public string Post([FromBody] DocumentRow Row) { return(DBConnection.AddRow(Row)); }
private static DocumentRow ParseRow(IExcelDataReader reader, Document parent) { var docRow = new DocumentRow(parent); for (var i = 0; i < reader.FieldCount; i++) docRow.Add(reader.GetString(i)); return docRow; }
// POST api/docuemntrow JToken json public string Post([FromBody] DocumentRow docRow) { return(dbRepository.AddDocumentRow(docRow)); }
public string AddDocumentRow(DocumentRow docRow) { return(DBConnection.AddRow(docRow)); }