コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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("Ошибка: не удалось добавить номенклатуру");
        }
コード例 #8
0
 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();
 }
コード例 #9
0
        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;
        }
コード例 #10
0
        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;
        }
コード例 #11
0
 // POST api/docuemntrow  JToken json
 public string Post([FromBody] DocumentRow Row)
 {
     return(DBConnection.AddRow(Row));
 }
コード例 #12
0
 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;
 }
コード例 #13
0
 // POST api/docuemntrow  JToken json
 public string Post([FromBody] DocumentRow docRow)
 {
     return(dbRepository.AddDocumentRow(docRow));
 }
コード例 #14
0
 public string AddDocumentRow(DocumentRow docRow)
 {
     return(DBConnection.AddRow(docRow));
 }