Ejemplo n.º 1
0
        protected void lnkCompleteOrder_OnCommand(object sender, CommandEventArgs e)
        {
            STG_ServiceWork         stg_servWork = Session["stg_servWork"] as STG_ServiceWork;
            ServiceWorkToBeDoneList workList     = Session["workList"] as ServiceWorkToBeDoneList;

            // create an invoice
            Invoice newInvoice = new Invoice();

            newInvoice.AccountID   = Convert.ToInt32(lblAccountNumber.Text);
            newInvoice.InvoiceDate = DateTime.Now.ToLocalTime();
            newInvoice.CreatedBy   = User.Identity.Name.ToString();
            //add service work subtotal + invoicelineitems subtotal
            double totalServiceWorkCharge    = ServiceWork.CalculateTotalWorkCharge(workList);
            double totalServiceWorkChargeTax = ServiceWork.CalculateTotalTax(totalServiceWorkCharge, taxPercentage);

            newInvoice.SubTotal = totalServiceWorkCharge;

            //add service work tax + invoicelineitem tax
            newInvoice.TotalTaxCharged = totalServiceWorkChargeTax;

            //
            newInvoice.TotalAmount = (totalServiceWorkCharge + totalServiceWorkChargeTax);


            newInvoice.InvoiceID = InvoiceManager.Save(newInvoice);

            // save service work using stg_service work and invoice ID from invoice
            ServiceWork sWork = new ServiceWork();

            sWork.AccountID        = stg_servWork.AccountID;
            sWork.ServiceDate      = stg_servWork.ServiceDate;
            sWork.ServiceStartTime = stg_servWork.ServiceStartTime;
            sWork.ServiceEndTime   = stg_servWork.ServiceEndTime;
            //sWork.ServiceStatus = stg_servWork.ServiceStatus;
            sWork.Technician    = ddlTechnician.SelectedValue.ToString();
            sWork.InvoiceID     = newInvoice.InvoiceID;
            sWork.SubTotal      = totalServiceWorkCharge;
            sWork.TaxCharged    = totalServiceWorkChargeTax;
            sWork.ServiceWorkID = ServiceWorkManager.Save(sWork);

            // save service work to be done using service work ID

            foreach (ServiceWorkToBeDone sWorkToBeDone in workList)
            {
                sWorkToBeDone.ServiceWorkID = sWork.ServiceWorkID;
                //save each work to be done in the DB
                sWorkToBeDone.WorkToBeDoneID = ServiceWorkToBeDoneManager.Save(sWorkToBeDone);
            }


            //clear the session variables
            PerformSessionCleanup();
        }
Ejemplo n.º 2
0
 private void PopulateGridView()
 {
     gviewWorkItems.DataSource = ServiceWorkToBeDoneManager.GetListByServiceWorkID(_serviceWorkID);
     gviewWorkItems.DataBind();
 }