public void Execute(DataTable dataTableForInvoiceDetails, InvoiceDetailCM model)
 {
     using (var sqlCommand = CreateCommand())
     {
         sqlCommand.Connection  = Connection;
         sqlCommand.CommandText = "[dbo].[uspAddInvoiceDetails]";
         sqlCommand.CommandType = CommandType.StoredProcedure;
         sqlCommand.Parameters.Add(AddParameter("@InvoiceDetails", SsDbType.Structured, ParameterDirection.Input, dataTableForInvoiceDetails));
         sqlCommand.ExecuteNonQuery();
     }
 }
Пример #2
0
        public void AddInvoiceDetails(InvoiceDetailCM InvoiceDetailCM)
        {
            using (var connection = new DbConnectionProvider().CreateConnection())
            {
                connection.Open();

                var command = new InvoiceDetailsInsertCommand {
                    Connection = connection
                };
                command.Execute(InvoiceDetailCM.InvoiceDetailsItems.ToDataTableWithNull(), InvoiceDetailCM);
            }
        }
        public AddInvoiceResponseDto AddInvoice(AddInvoiceRequestDto addInvoiceRequestDto)
        {
            AddInvoiceResponseDto response = new AddInvoiceResponseDto();

            if (addInvoiceRequestDto.IsNew)
            {
                #region InvoiceDetails

                var invoiceDetailsItemsCM = new List <InvoiceDetailsItems>();
                var invoiceDetailsCM      = new InvoiceDetailCM();

                foreach (var invoiceDetails in addInvoiceRequestDto.GetInvoiceDetailList)
                {
                    var invoiceDetailsItems = new InvoiceDetailsItems
                    {
                        InvoiceNumber   = addInvoiceRequestDto.InvoiceNumber,
                        InvoiceSerial   = invoiceDetails.InvoiceSerial,
                        DcNumber        = invoiceDetails.DcNumber,
                        PartCode        = invoiceDetails.PartCode,
                        Quantity        = invoiceDetails.Quantity,
                        Rate            = invoiceDetails.Rate,
                        Value           = invoiceDetails.Value,
                        Remarks         = invoiceDetails.Remarks,
                        DcSerial        = invoiceDetails.DcSerial,
                        CreatedBy       = new Guid("783F190B-9B66-42AC-920B-E938732C1C01"), //Later needs to be remove
                        CreatedDateTime = System.DateTime.UtcNow
                    };

                    invoiceDetailsItemsCM.Add(invoiceDetailsItems);
                }

                invoiceDetailsCM.InvoiceDetailsItems = invoiceDetailsItemsCM;

                invoiceRepository.AddInvoiceDetails(invoiceDetailsCM);

                #endregion

                #region InvoiceMaster

                invoiceRepository.AddInvoiceMaster(addInvoiceRequestDto.InvoiceNumber, addInvoiceRequestDto.InvoiceDate, addInvoiceRequestDto.DcNumber,
                                                   addInvoiceRequestDto.WoType, addInvoiceRequestDto.VendorCode, addInvoiceRequestDto.Tariff, addInvoiceRequestDto.Vehicle,
                                                   addInvoiceRequestDto.EWayBill, addInvoiceRequestDto.CGSTPercent, addInvoiceRequestDto.SGSTPercent,
                                                   addInvoiceRequestDto.IGSTPercent, addInvoiceRequestDto.ValueOfGoods, addInvoiceRequestDto.CGSTAmount,
                                                   addInvoiceRequestDto.SGSTAmount, addInvoiceRequestDto.IGSTAmount, addInvoiceRequestDto.GrandTotal,
                                                   addInvoiceRequestDto.RoundOff, addInvoiceRequestDto.FineTotal, addInvoiceRequestDto.PrintTag);

                #endregion

                var model = invoiceRepository.GetDcDetailsSerialForInvoiceSerial(addInvoiceRequestDto.DcNumber);

                #region InvoiceDetailsSerial
                var invoiceDetailSerialItemCM = new List <InvoiceDetailSerialItem>();
                var invoiceDetailSerialCM     = new InvoiceDetailSerialCM();

                foreach (var invoiceDetailsSerial in model.GetDcSerialForInvoiceSerialQMList)
                {
                    var invoiceDetailSerialItem = new InvoiceDetailSerialItem
                    {
                        InvoiceNumber   = addInvoiceRequestDto.InvoiceNumber,
                        InvoiceSerial   = invoiceDetailsSerial.InvoiceSerial,
                        DcNumber        = invoiceDetailsSerial.DcNumber,
                        DcSerial        = invoiceDetailsSerial.DcSerial,
                        SerialNo        = invoiceDetailsSerial.SerialNo,
                        WoNumber        = invoiceDetailsSerial.WoNumber,
                        WoSerial        = invoiceDetailsSerial.WoSerial,
                        CreatedBy       = new Guid("783F190B-9B66-42AC-920B-E938732C1C01"), //Later needs to be remove
                        CreatedDateTime = System.DateTime.UtcNow
                    };

                    invoiceDetailSerialItemCM.Add(invoiceDetailSerialItem);
                }

                invoiceDetailSerialCM.InvoiceDetailSerialItem = invoiceDetailSerialItemCM;

                invoiceRepository.AddInvoiceDetailSerial(invoiceDetailSerialCM);
                #endregion
            }
            else
            {
                #region InvoiceDetails Update

                var invoiceDetailsItemsCM = new List <InvoiceDetailsItems>();
                var invoiceDetailsCM      = new InvoiceDetailCM();

                foreach (var invoiceDetails in addInvoiceRequestDto.GetInvoiceDetailList)
                {
                    var invoiceDetailsItems = new InvoiceDetailsItems
                    {
                        InvoiceNumber   = addInvoiceRequestDto.InvoiceNumber,
                        InvoiceSerial   = invoiceDetails.InvoiceSerial,
                        DcNumber        = invoiceDetails.DcNumber,
                        PartCode        = invoiceDetails.PartCode,
                        Quantity        = invoiceDetails.Quantity,
                        Rate            = invoiceDetails.Rate,
                        Value           = invoiceDetails.Value,
                        Remarks         = invoiceDetails.Remarks,
                        DcSerial        = invoiceDetails.DcSerial,
                        CreatedBy       = new Guid("783F190B-9B66-42AC-920B-E938732C1C01"), //Later needs to be remove
                        CreatedDateTime = System.DateTime.UtcNow
                    };

                    invoiceDetailsItemsCM.Add(invoiceDetailsItems);
                }

                invoiceDetailsCM.InvoiceDetailsItems = invoiceDetailsItemsCM;

                invoiceRepository.UpdateInvoiceDetails(invoiceDetailsCM);

                #endregion

                #region InvoiceMaster Update

                invoiceRepository.UpdateInvoiceMaster(addInvoiceRequestDto.InvoiceNumber, addInvoiceRequestDto.InvoiceDate, addInvoiceRequestDto.DcNumber,
                                                      addInvoiceRequestDto.WoType, addInvoiceRequestDto.VendorCode, addInvoiceRequestDto.Tariff, addInvoiceRequestDto.Vehicle,
                                                      addInvoiceRequestDto.EWayBill, addInvoiceRequestDto.CGSTPercent, addInvoiceRequestDto.SGSTPercent,
                                                      addInvoiceRequestDto.IGSTPercent, addInvoiceRequestDto.ValueOfGoods, addInvoiceRequestDto.CGSTAmount,
                                                      addInvoiceRequestDto.SGSTAmount, addInvoiceRequestDto.IGSTAmount, addInvoiceRequestDto.GrandTotal,
                                                      addInvoiceRequestDto.RoundOff, addInvoiceRequestDto.FineTotal);

                #endregion
            }

            return(response);
        }