Example #1
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;
        }
    }