예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            wizardData wData;

            if (!Page.IsPostBack)
            {
                pageTitle = ConfigurationManager.AppSettings["AppTitle"].ToString() + "Τιμολόγια > Δημιουργία Νέου Τιμολογίου";
                dpDateFrom.SelectedDate    = DateTime.Now.Date;
                dpDateTo.SelectedDate      = DateTime.Now.Date;
                dpDateCreated.SelectedDate = DateTime.Now.Date;
                dpDatePay.SelectedDate     = DateTime.Now.Date.AddDays(30);
                wData                 = new wizardData();
                wData.Step            = 1;
                Session["wizardStep"] = wData;
                showWizardSteps(wData);
                try {
                    CustomersController cont = new CustomersController();
                    ddlCustomers.DataSource     = cont.GetCustomersForCountry(1);
                    ddlCustomers.DataTextField  = "NameGR";
                    ddlCustomers.DataValueField = "ID";
                    ddlCustomers.DataBind();
                }
                catch (Exception) { }
            }
            if (Session["LoggedUser"] != null)
            {
                loggedUser = Session["LoggedUser"] as UserB;
            }
            else
            {
                Response.Redirect("/Default.aspx", true);
            }
        }
예제 #2
0
        protected void btnShowPrev4_Click(object sender, EventArgs e)
        {
            wizardData wData = readWizardSteps();

            wData.Step            = 3;
            Session["wizardStep"] = wData;
            showWizardSteps(wData);
        }
예제 #3
0
 protected void gridTasks_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
 {
     try {
         wizardData      wData = readWizardSteps();
         TasksController tcont = new TasksController();
         gridTasks.DataSource = tcont.GetTasksForInvoice(wData.CustomerID, wData.DateFrom, wData.DateTo, wData.SelectedJobs).OrderBy(o => o.DateTimeStartOrder);
     }
     catch (Exception) { }
 }
예제 #4
0
        protected void btnShow4_Click(object sender, EventArgs e)
        {
            wizardData wData = readWizardSteps();

            using (var dbContext = new OTERTConnStr()) {
                try {
                    dbContext.Configuration.ProxyCreationEnabled = false;
                    OTERT_Entity.Invoices curInvoice;
                    curInvoice             = new OTERT_Entity.Invoices();
                    curInvoice.CustomerID  = wData.CustomerID;
                    curInvoice.DateFrom    = wData.DateFrom;
                    curInvoice.DateTo      = wData.DateTo;
                    curInvoice.RegNo       = wData.Code;
                    curInvoice.IsLocked    = wData.locked;
                    curInvoice.DatePaid    = wData.DatePayed;
                    curInvoice.DateCreated = wData.DateCreated;
                    TasksController tcont          = new TasksController();
                    List <TaskB>    invTasks       = tcont.GetTasksForInvoice(curInvoice.CustomerID, wData.DateFrom, wData.DateTo, wData.SelectedJobs, wData.SelectedTasks);
                    decimal         totalTasksCost = 0;
                    foreach (TaskB curTask in invTasks)
                    {
                        totalTasksCost += curTask.CostActual.GetValueOrDefault();
                    }
                    curInvoice.TasksLineAmount = totalTasksCost;

                    /*
                     * foreach (GridDataItem item in gridSales.MasterTableView.Items) {
                     *  CheckBox chk = (CheckBox)item.FindControl("chk");
                     *  decimal? tasksValue = decimal.Parse(item["TasksCost"].Text);
                     *  decimal? salesValue = decimal.Parse(item["SalesCost"].Text);
                     *  curInvoice.TasksLineAmount = tasksValue;
                     *  if (chk.Checked) {
                     *      curInvoice.DiscountLineAmount = salesValue;
                     *  }
                     *  dbContext.Invoices.Add(curInvoice);
                     * }
                     */
                    dbContext.Invoices.Add(curInvoice);
                    dbContext.SaveChanges();
                    foreach (TaskB curTask in invTasks)
                    {
                        TasksLine newTaskLine = new TasksLine();
                        newTaskLine.InvoiceID = curInvoice.ID;
                        newTaskLine.TaskID    = curTask.ID;
                        newTaskLine.JobID     = curTask.JobID.GetValueOrDefault();
                        dbContext.TasksLine.Add(newTaskLine);
                    }
                    dbContext.SaveChanges();
                }
                catch (Exception) { }
                Response.Redirect("/Pages/Invoices/InvoiceShow.aspx", false);
            }
            //Session["wizardStep"] = wData;
            //showWizardSteps(wData);
        }
예제 #5
0
        protected void btnShow1_Click(object sender, EventArgs e)
        {
            wizardData wData = readWizardSteps();

            wData.Step            = 2;
            wData.CustomerID      = int.Parse(ddlCustomers.SelectedItem.Value);
            wData.DateFrom        = (dpDateFrom.SelectedDate != null ? (DateTime)dpDateFrom.SelectedDate : DateTime.Now);
            wData.DateTo          = (dpDateTo.SelectedDate != null ? (DateTime)dpDateTo.SelectedDate : DateTime.Now);
            wData.DateCreated     = (dpDateCreated.SelectedDate != null ? (DateTime)dpDateCreated.SelectedDate : DateTime.Now);
            wData.Code            = txtAccountNo.Text.Trim();
            wData.DatePayed       = (dpDatePay.SelectedDate != null ? (DateTime)dpDatePay.SelectedDate : DateTime.Now);
            wData.locked          = (chkIsLocked.Checked != null ? (bool)chkIsLocked.Checked : false);
            Session["wizardStep"] = wData;
            showWizardSteps(wData);
            gridJobs.Rebind();
        }
예제 #6
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            wizardData wData = readWData();

            using (var dbContext = new OTERTConnStr()) {
                try {
                    dbContext.Configuration.ProxyCreationEnabled = false;
                    OTERT_Entity.Invoices curInvoice = dbContext.Invoices.Where(o => o.ID == wData.CustomerID).FirstOrDefault();
                    curInvoice.RegNo    = txtAccountNo.Text.Trim();
                    curInvoice.IsLocked = (chkIsLocked.Checked != null ? (bool)chkIsLocked.Checked : false);
                    curInvoice.DatePaid = (dpDatePay.SelectedDate != null ? (DateTime)dpDatePay.SelectedDate : DateTime.Now);
                    dbContext.SaveChanges();
                }
                catch (Exception ex) { }
                Response.Redirect("/Pages/Invoices/InvoiceShow.aspx", false);
            }
        }
예제 #7
0
        protected void btnShow2_Click(object sender, EventArgs e)
        {
            wizardData wData = readWizardSteps();

            wData.Step         = 3;
            wData.SelectedJobs = new List <string>();
            foreach (GridDataItem item in gridJobs.MasterTableView.Items)
            {
                CheckBox chk   = (CheckBox)item.FindControl("chk");
                string   value = item.GetDataKeyValue("ID").ToString();
                if (chk.Checked)
                {
                    wData.SelectedJobs.Add(value);
                }
            }
            Session["wizardStep"] = wData;
            showWizardSteps(wData);
            gridTasks.Rebind();
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            wizardData wData;

            if (!Page.IsPostBack)
            {
                pageTitle = ConfigurationManager.AppSettings["AppTitle"].ToString() + "Τιμολόγια > Επεξεργασία Τιμολογίου";
                int invoiceID = -1;
                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    int.TryParse(Request.QueryString["ID"], out invoiceID);
                }
                wData = new wizardData();
                if (invoiceID > 0)
                {
                    try {
                        InvoicesController cont          = new InvoicesController();
                        InvoiceB           singleInvoice = cont.GetInvoice(invoiceID);
                        if (singleInvoice != null)
                        {
                            lblCustomer.Text       = singleInvoice.Customer.NameGR;
                            lblDateFrom.Text       = singleInvoice.DateFrom.GetValueOrDefault().ToString("dd/MM/yyyy");
                            lblDateTo.Text         = singleInvoice.DateTo.GetValueOrDefault().ToString("dd/MM/yyyy");
                            lblDateCreated.Text    = singleInvoice.DateCreated.GetValueOrDefault().ToString("dd/MM/yyyy");
                            txtAccountNo.Text      = singleInvoice.RegNo;
                            dpDatePay.SelectedDate = singleInvoice.DatePaid;
                            chkIsLocked.Checked    = singleInvoice.IsLocked;
                            wData.CustomerID       = invoiceID;
                        }
                    }
                    catch (Exception) { }
                }
                Session["wizardStep"] = wData;
            }
            if (Session["LoggedUser"] != null)
            {
                loggedUser = Session["LoggedUser"] as UserB;
            }
            else
            {
                Response.Redirect("/Default.aspx", true);
            }
        }
예제 #9
0
        protected void showWizardSteps(wizardData wData)
        {
            switch (wData.Step)
            {
            case 1:
                phStep1.Visible = true;
                phStep2.Visible = false;
                phStep3.Visible = false;
                phStep4.Visible = false;
                break;

            case 2:
                phStep1.Visible = false;
                phStep2.Visible = true;
                phStep3.Visible = false;
                phStep4.Visible = false;
                break;

            case 3:
                phStep1.Visible = false;
                phStep2.Visible = false;
                phStep3.Visible = true;
                phStep4.Visible = false;
                break;

            case 4:
                phStep1.Visible = false;
                phStep2.Visible = false;
                phStep3.Visible = false;
                phStep4.Visible = true;
                break;

            default:
                phStep1.Visible = false;
                phStep2.Visible = false;
                phStep3.Visible = false;
                phStep4.Visible = false;
                break;
            }
        }
예제 #10
0
        protected void btnShow3_Click(object sender, EventArgs e)
        {
            wizardData wData = readWizardSteps();

            wData.Step          = 4;
            wData.SelectedTasks = new List <string>();
            foreach (GridDataItem item in gridTasks.MasterTableView.Items)
            {
                CheckBox chk   = (CheckBox)item.FindControl("chk");
                string   value = item.GetDataKeyValue("ID").ToString();
                if (chk.Checked)
                {
                    wData.SelectedTasks.Add(value);
                }
            }
            //Session["wizardStep"] = wData;
            //showWizardSteps(wData);
            //gridSales.Rebind();
            //wizardData wData = readWizardSteps();
            using (var dbContext = new OTERTConnStr()) {
                try {
                    dbContext.Configuration.ProxyCreationEnabled = false;
                    OTERT_Entity.Invoices curInvoice;
                    curInvoice             = new OTERT_Entity.Invoices();
                    curInvoice.CustomerID  = wData.CustomerID;
                    curInvoice.DateFrom    = wData.DateFrom;
                    curInvoice.DateTo      = wData.DateTo;
                    curInvoice.RegNo       = wData.Code;
                    curInvoice.IsLocked    = wData.locked;
                    curInvoice.DatePaid    = wData.DatePayed;
                    curInvoice.DateCreated = wData.DateCreated;
                    TasksController tcont          = new TasksController();
                    List <TaskB>    invTasks       = tcont.GetTasksForInvoice(curInvoice.CustomerID, wData.DateFrom, wData.DateTo, wData.SelectedJobs, wData.SelectedTasks);
                    decimal         totalTasksCost = 0;
                    foreach (TaskB curTask in invTasks)
                    {
                        totalTasksCost += curTask.CostActual.GetValueOrDefault();
                    }
                    curInvoice.TasksLineAmount = totalTasksCost;
                    dbContext.Invoices.Add(curInvoice);
                    dbContext.SaveChanges();
                    foreach (TaskB curTask in invTasks)
                    {
                        TasksLine newTaskLine = new TasksLine();
                        newTaskLine.InvoiceID = curInvoice.ID;
                        newTaskLine.TaskID    = curTask.ID;
                        newTaskLine.JobID     = curTask.JobID.GetValueOrDefault();
                        Tasks curTaskEntity = dbContext.Tasks.Where(s => s.ID == curTask.ID).First();
                        curTaskEntity.IsLocked = true;
                        DateTime dnow = DateTime.Now;
                        //curTaskEntity.PaymentDateActual = dnow;
                        curTaskEntity.PaymentDateCalculated = wData.DatePayed;
                        curTaskEntity.PaymentDateOrder      = wData.DateCreated;
                        dbContext.TasksLine.Add(newTaskLine);
                    }
                    dbContext.SaveChanges();
                }
                catch (Exception) { }
                Response.Redirect("~/Pages/Invoices/InvoiceShow.aspx", false);
            }
        }
예제 #11
0
 protected void gridSales_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
 {
     try {
         wizardData               wData          = readWizardSteps();
         TasksController          tcont          = new TasksController();
         SalesFormulasController  sfcont         = new SalesFormulasController();
         List <TaskB>             selectedTasks  = tcont.GetTasksForInvoice(wData.CustomerID, wData.DateFrom, wData.DateTo, wData.SelectedJobs, wData.SelectedTasks).OrderBy(o => o.DateTimeStartOrder).ToList();
         List <int>               distinctJobsID = selectedTasks.Where(x => x.JobID != null).Select(x => x.JobID.Value).Distinct().ToList();
         List <tasksTotalsPerJob> tot            = new List <tasksTotalsPerJob>();
         foreach (int curJobID in distinctJobsID)
         {
             List <SalesFormulaB> curSaleFormulas = new List <SalesFormulaB>();
             tasksTotalsPerJob    curTotal        = new tasksTotalsPerJob();
             curTotal.JobID = curJobID;
             List <TaskB> tasksForJobID = selectedTasks.Where(x => x.JobID == curJobID).ToList();
             curTotal.JobName = tasksForJobID.First().Job.Name;
             int?salesID = tasksForJobID.First().Job.SalesID;
             if (salesID != null)
             {
                 curSaleFormulas = sfcont.GetSalesFormulas(salesID.Value);
             }
             curTotal.TasksCount = tasksForJobID.Count();
             curTotal.TasksCost  = 0;
             curTotal.SalesCost  = 0;
             foreach (TaskB curTask in tasksForJobID)
             {
                 if (curTask.CostActual != null)
                 {
                     curTotal.TasksCost += curTask.CostActual.Value;
                     if (curSaleFormulas.Count > 0)
                     {
                         if (curSaleFormulas.First().Sale.Type == 1)
                         {
                             decimal tmpKM      = curTask.Distance.KM;
                             decimal tmpKmToChk = 0;
                             foreach (SalesFormulaB sf in curSaleFormulas)
                             {
                                 decimal distanceValue = (sf.Distance != null ? sf.Distance.Value : 0);
                                 if (tmpKM >= distanceValue - tmpKmToChk)
                                 {
                                     curTotal.SalesCost += curTotal.TasksCost * sf.SalePercent / 100;
                                     tmpKM      -= distanceValue;
                                     tmpKmToChk += distanceValue;
                                 }
                                 else
                                 {
                                     curTotal.SalesCost += curTotal.TasksCost * sf.SalePercent / 100;
                                     break;
                                 }
                             }
                         }
                         else if (curSaleFormulas.First().Sale.Type == 2)
                         {
                             decimal salePercent = 0;
                             if (curTask.Distance.KM > curSaleFormulas.Last().Distance)
                             {
                                 salePercent = curSaleFormulas.Last().SalePercent;
                             }
                             else
                             {
                                 foreach (SalesFormulaB sf in curSaleFormulas)
                                 {
                                     if (curTask.Distance.KM <= sf.Distance)
                                     {
                                         salePercent = sf.SalePercent;
                                         break;
                                     }
                                 }
                             }
                             curTotal.SalesCost += curTotal.TasksCost * salePercent / 100;
                         }
                     }
                 }
             }
             tot.Add(curTotal);
         }
         gridSales.DataSource = tot;
     }
     catch (Exception) { }
 }
예제 #12
0
        protected wizardData readWizardSteps()
        {
            wizardData wData = (Session["wizardStep"] != null ? (wizardData)Session["wizardStep"] : new wizardData());

            return(wData);
        }