Пример #1
0
        public void Update(
            int id,
            DateTime date,
            DateTime startDate,
            DateTime?endDate,
            string customerCode,
            int documentTypeID,
            string notes)
        {
            ChangeStatusDocument doc  = context.ChangeStatusDocuments.Single(d => d.ID == id);
            Customer             cust = context.Customers.SingleOrDefault(c => c.Barcode == customerCode);
            Employee             emp  = context.Employees.SingleOrDefault(e => e.UserName == principal.Identity.Name);

            if (cust != null && doc != null && emp != null)
            {
                doc.Date           = date;
                doc.StartDate      = startDate;
                doc.EndDate        = endDate;
                doc.CustomerID     = cust.ID;
                doc.EmployeeID     = emp.ID;
                doc.DocumentTypeID = documentTypeID;
                doc.Notes          = notes;
                doc.VoidDate       = null;
                EntityHelper.SetAuditFieldForUpdate(doc, principal.Identity.Name);



                context.SaveChanges();
            }
        }
Пример #2
0
        public void Add(
            int branchID,
            DateTime date,
            DateTime startDate,
            DateTime?endDate,
            string customerCode,
            int documentTypeID,
            string notes)
        {
            Customer cust = context.Customers.SingleOrDefault(c => c.Barcode == customerCode);
            Employee emp  = context.Employees.SingleOrDefault(e => e.UserName == principal.Identity.Name);

            if (cust != null && emp != null)
            {
                ChangeStatusDocument doc = new ChangeStatusDocument();
                doc.BranchID       = branchID;
                doc.DocumentNo     = autoNumberProvider.Generate(branchID, "CS", date.Month, date.Year);
                doc.Date           = date;
                doc.StartDate      = startDate;
                doc.EndDate        = endDate;
                doc.CustomerID     = cust.ID;
                doc.EmployeeID     = emp.ID;
                doc.DocumentTypeID = documentTypeID;
                doc.Notes          = notes;
                doc.VoidDate       = null;
                EntityHelper.SetAuditFieldForInsert(doc, principal.Identity.Name);
                context.Add(doc);

                autoNumberProvider.Increment("CS", doc.BranchID, doc.Date.Year);
                context.SaveChanges();
            }
        }
        protected void gvwMaster_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("EditRow"))
            {
                mvwForm.ActiveViewIndex = 1;
                RowID = Convert.ToInt32(e.CommandArgument);
                ddlDocumentType.Enabled = false;
                ChangeStatusDocument doc = DocumentService.GetChangeStatusDocument(RowID);
                lblBranch.Text                = doc.Branch.Name;
                txtCustomerCode.Text          = doc.Customer.Barcode;
                txtNotes.Text                 = doc.Notes;
                ddlDocumentType.SelectedValue = doc.DocumentTypeID.ToString();
                calStartDate.SelectedDate     = doc.StartDate;
                chkEndDate.Checked            = doc.EndDate.HasValue;
                if (doc.EndDate.HasValue)
                {
                    calEndDate.SelectedDate = doc.EndDate.Value;
                }
                else
                {
                    calEndDate.Clear();
                }
                lblDocumentNo.Text = String.Format("{0} - {1}", doc.DocumentNo, doc.Date.ToLongDateString());

                if (doc.VoidDate.HasValue)
                {
                    lblApprovalStatus.Text = "Void";
                }
                else if (doc.ApprovedDate.HasValue)
                {
                    lblApprovalStatus.Text = "Approved";
                }
                else
                {
                    lblApprovalStatus.Text = "Not Approved";
                }

                btnVoid.Enabled    = !doc.VoidDate.HasValue;
                btnApprove.Enabled = EmployeeService.CanApproveDocument(User.Identity.Name);
                btnApprove.Enabled = !doc.ApprovedDate.HasValue && !doc.VoidDate.HasValue && RowID > 0;
                btnSave.Enabled    = !doc.VoidDate.HasValue && !doc.ApprovedDate.HasValue;

                if (String.IsNullOrEmpty(hypPromptCustomer.Attributes["onclick"]))
                {
                    hypPromptCustomer.Attributes.Add("onclick",
                                                     String.Format(
                                                         "showPromptPopUp('PromptCustomer.aspx?BranchID={0}', '{1}', 550, 900);",
                                                         ddlFindBranch.SelectedValue, txtCustomerCode.ClientID));
                }
            }
        }
Пример #4
0
    protected void gvwMaster_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("EditRow"))
        {
            mvwForm.ActiveViewIndex = 1;
            RowID = Convert.ToInt32(e.CommandArgument);
            ddlDocumentType.Enabled = false;
            ChangeStatusDocument doc = documentProvider.GetChangeStatusDocument(RowID);
            lblBranch.Text                = doc.Branch.Name;
            txtCustomerCode.Text          = doc.Customer.Barcode;
            txtNotes.Text                 = doc.Notes;
            ddlDocumentType.SelectedValue = doc.DocumentTypeID.ToString();
            calStartDate.SelectedDate     = doc.StartDate;
            chkEndDate.Checked            = doc.EndDate.HasValue;
            if (doc.EndDate.HasValue)
            {
                calEndDate.SelectedDate = doc.EndDate.Value;
            }
            else
            {
                calEndDate.Clear();
            }
            lblDocumentNo.Text = String.Format("{0} - {1}", doc.DocumentNo, doc.Date.ToLongDateString());

            if (doc.VoidDate.HasValue)
            {
                lblApprovalStatus.Text = "Void";
            }
            else if (doc.ApprovedDate.HasValue)
            {
                lblApprovalStatus.Text = "Approved";
            }
            else
            {
                lblApprovalStatus.Text = "Not Approved";
            }

            btnVoid.Enabled    = !doc.VoidDate.HasValue;
            btnApprove.Enabled = employeeProvider.CanApproveDocument(User.Identity.Name);
            btnApprove.Enabled = !doc.ApprovedDate.HasValue && !doc.VoidDate.HasValue && RowID > 0;
            btnSave.Enabled    = !doc.VoidDate.HasValue && !doc.ApprovedDate.HasValue;
        }
    }
Пример #5
0
        public void Approve(int id)
        {
            ChangeStatusDocument doc = context.ChangeStatusDocuments.Single(d => d.ID == id);
            Employee             emp = context.Employees.SingleOrDefault(e => e.ID == doc.EmployeeID);

            if (emp != null && doc != null)
            {
                doc.ApprovedDate         = DateTime.Now;
                doc.ApprovedByEmployeeID = emp.ID;
                EntityHelper.SetAuditFieldForUpdate(doc, principal.Identity.Name);

                CustomerStatusHistory csh = new CustomerStatusHistory();
                csh.StartDate            = doc.StartDate;
                csh.EndDate              = doc.EndDate;
                csh.Notes                = doc.Notes;
                csh.CustomerID           = doc.CustomerID;
                csh.Date                 = DateTime.Today;
                csh.ChangeStatusDocument = doc;
                EntityHelper.SetAuditFieldForInsert(csh, principal.Identity.Name);

                if (doc.DocumentType.ChangeCustomerStatusIDTo.HasValue)
                {
                    csh.CustomerStatusID = doc.DocumentType.ChangeCustomerStatusIDTo.Value;
                }

                //if (doc.DocumentType.IsLastState)
                //{
                //    foreach (Contract activeContract in doc.Customer.Contracts.Where(con => con.Status == ContractStatus.PAID))
                //        activeContract.Status = ContractStatus.CLOSED;
                //}

                context.Add(csh);

                context.SaveChanges();
            }
        }