コード例 #1
0
ファイル: ServiceWork.cs プロジェクト: fpantos/ProjectAqua
        public static double CalculateTotalWorkCharge(ServiceWorkToBeDoneList workToBeDoneList)
        {
            double subTotal = 0;

            foreach (ServiceWorkToBeDone s in workToBeDoneList)
            {
                subTotal += s.WorkCharge;
            }
            return(subTotal);
        }
コード例 #2
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();
        }
コード例 #3
0
        protected void lnkAddToWorkOrderGrid_OnCommand(object sender, CommandEventArgs e)
        {
            DropDownList ddlWorkType = (fviewWork.FindControl("ddlWorkType") as DropDownList);

            if (ddlWorkType.SelectedIndex == 0)
            {
                // display a label about making a work type selection
                lblMessage.Text      = "Please select a work type";
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                //add the work order

                //create a new serviceWorkToBeDone object
                ServiceWorkToBeDone serviceWorkTBD = new ServiceWorkToBeDone();
                serviceWorkTBD.WorkType   = (fviewWork.FindControl("ddlWorkType") as DropDownList).SelectedItem.Text;
                serviceWorkTBD.WorkCharge = double.Parse((fviewWork.FindControl("txtWorkCharge") as TextBox).Text.ToString(), CultureInfo.InvariantCulture); //100;
                serviceWorkTBD.WorkNotes  = (fviewWork.FindControl("txtWorkNotes") as TextBox).Text.Trim();

                //create the collection
                ServiceWorkToBeDoneList workList = new ServiceWorkToBeDoneList();

                // create a session variable
                if (Session["workList"] == null)
                {
                    workList.Add(serviceWorkTBD);
                    Session["workList"] = workList;
                }
                else
                {
                    workList = Session["workList"] as ServiceWorkToBeDoneList;
                    workList.Add(serviceWorkTBD);
                }

                gviewWorkList.DataSource = workList;
                gviewWorkList.DataBind();

                //reset the fields in the formview
                (fviewWork.FindControl("ddlWorkType") as DropDownList).SelectedIndex = 0;
                (fviewWork.FindControl("txtWorkCharge") as TextBox).Text             = "";
                (fviewWork.FindControl("txtWorkNotes") as TextBox).Text = "";

                lblMessage.Text = "";

                //enable the scheduler linkbutton
                lnkOpenScheduler.Enabled = true;
            }
        }
コード例 #4
0
        protected void vwFinalizeOrder_Activate(object sender, EventArgs e)
        {
            //display the work orders, replacement parts and service datetime

            ServiceWorkToBeDoneList w = Session["workList"] as ServiceWorkToBeDoneList;

            gviewWorkOrdersReview.DataSource = w;
            gviewWorkOrdersReview.DataBind();

            STG_ServiceWork stg_servWork = Session["stg_servWork"] as STG_ServiceWork;

            dtf = CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat;
            dtf.ShortDatePattern = myCustomShortDatePattern;

            lblReviewServiceDateTime.Text = stg_servWork.ServiceDate.ToString("ddd") + " " + stg_servWork.ServiceDate.ToString("d", dtf)
                                            + " - " + ddlServiceStartTime.SelectedValue.ToString() + " to " + ddlServiceEndTime.SelectedValue.ToString();

            lblReviewTechnician.Text = ddlTechnician.SelectedValue.ToString();
        }
コード例 #5
0
        protected void gviewWorkOrdersReview_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //Display the work charge sub total in the footer
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                ServiceWorkToBeDoneList workList = Session["workList"] as ServiceWorkToBeDoneList;

                if (workList != null)
                {
                    foreach (ServiceWorkToBeDone sWork in workList)
                    {
                        totalWorkCharge += sWork.WorkCharge;
                    }
                }

                e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right;
                e.Row.Cells[2].Text            = "Sub Total " + totalWorkCharge.ToString("c");
            }
        }
コード例 #6
0
        protected void gviewWorkList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int index = e.RowIndex;

            if (Session["workList"] != null)
            {
                ServiceWorkToBeDoneList workList = Session["workList"] as ServiceWorkToBeDoneList;
                workList.RemoveAt(index);

                gviewWorkList.DataSource = workList;
                gviewWorkList.DataBind();

                if (gviewWorkList.Rows.Count == 0)
                {
                    //disable the button to move to the next multiview
                    lnkGoToSetAppointmentDate.Enabled = false;
                }
            }
        }
コード例 #7
0
        public static ServiceWorkToBeDoneList GetListByServiceWorkID(int serviceWorkID)
        {
            ServiceWorkToBeDoneList aList  = null;
            MyDBConnection          myConn = new MyDBConnection();
            SqlConnection           conn   = new SqlConnection();
            SqlDataReader           dr;
            SqlCommand cmd = null;
            string     sql = "Select * from AquaOne.dbo.ServiceWorkToBeDone where serviceWorkID = @serviceWorkID";

            try
            {
                // Open the connection
                conn = myConn.OpenDB();
                cmd  = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@serviceWorkID", SqlDbType.Int).Value = serviceWorkID;

                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                if (dr.HasRows)
                {
                    aList = new ServiceWorkToBeDoneList();
                    while (dr.Read())
                    {
                        aList.Add(FillDataRecord(dr));
                    }
                }

                cmd.Dispose();
                dr.Close();
            }
            finally
            {
                myConn.CloseDB(conn);
            }

            return(aList);
        }