예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (SSITrainingEntities context = new SSITrainingEntities())
            {
                var allGroups = context.CompetencyGroups.OrderBy(i => i.GroupName);
                var allTypes  = context.CompetencyTypes.OrderBy(i => i.CompetencyTypeName);

                rptTabs.DataSource = allGroups.ToList();

                //rptPages.DataSource = allGroups.ToList();
                RadComboBoxType.DataSource     = allTypes.ToList();
                RadComboBoxEditType.DataSource = allTypes.ToList();
                RadComboBoxEditType.DataBind();
                RadComboBoxType.DataBind();
                rptTabs.DataBind();
                //rptPages.DataBind();
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id = Convert.ToInt32(Request["id"]);

            if (!IsPostBack)
            {
                foreach (GridColumn v in RadGridPurchaseOrderDetail.Columns)
                {
                    if (v.GetType() == typeof(GridTemplateColumn))
                    {
                        var column = (GridTemplateColumn)v;
                        switch (column.UniqueName)
                        {
                        case "Quantity":
                            column.DefaultInsertValue = "1";
                            break;
                        }
                    }
                }

                var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1");
                //scriptManager.Scripts.Add(new ScriptReference() { Path = ResolveUrl("~/assets/js/jquery.printArea.js") });
                //scriptManager.RegisterPostBackControl(RadButtonFileDownload);
                FileDownloadList1.InitFileDownloadList((int)CConstValue.Upload.PurchaseOrder);

                var global = new CGlobal();
                RadComboBoxType.DataSource     = global.GetDictionary(1466);
                RadComboBoxType.DataTextField  = "Name";
                RadComboBoxType.DataValueField = "Value";
                RadComboBoxType.DataBind();

                RadComboBoxPriority.DataSource     = global.GetDictionary(1470);
                RadComboBoxPriority.DataTextField  = "Name";
                RadComboBoxPriority.DataValueField = "Value";
                RadComboBoxPriority.DataBind();

                RadComboBoxShippingMethod.DataSource     = global.GetDictionary(1471);
                RadComboBoxShippingMethod.DataTextField  = "Name";
                RadComboBoxShippingMethod.DataValueField = "Value";
                RadComboBoxShippingMethod.DataBind();

                RadComboBoxReviewType.DataSource     = global.GetDictionary(1489);
                RadComboBoxReviewType.DataTextField  = "Name";
                RadComboBoxReviewType.DataValueField = "Value";
                RadComboBoxReviewType.DataBind();
                RadComboBoxReviewType.Items.Add(new RadComboBoxItem("N/A", null));
                RadComboBoxReviewType.SelectedIndex = RadComboBoxReviewType.Items.Count - 1;

                var obj = new CPurchaseOrder();
                var requestOrApprovalType = Request["requestOrApprovalType"];
                var approvalType          = Request["approvalType"];

                var buttonList = new List <string>();

                // new
                if (Request["createOrListType"] == "0")
                {
                    obj = obj.GetNewDocument(CurrentUserId);

                    buttonList.Add("TempSave");
                    buttonList.Add("Request");
                    buttonList.Add("Close");

                    SetVisibleItems(true);
                }
                // select
                else
                {
                    FileDownloadList1.GetFileDownload(Convert.ToInt32(Id));

                    // date
                    obj = new CPurchaseOrder(Id);

                    // request list
                    if (requestOrApprovalType == "0")
                    {
                        // Revise
                        if (approvalType == ((int)CConstValue.ApprovalStatus.Revise).ToString())
                        {
                            buttonList.Add("Request");
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(true);
                        }
                        // TempSave
                        else if (approvalType == string.Empty)
                        {
                            buttonList.Add("TempSave");
                            buttonList.Add("Request");
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(true);
                        }
                        // Request
                        else if (approvalType == "1")
                        {
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(false);
                        }
                        else
                        {
                            buttonList.Add("Close");

                            SetVisibleItems(false);
                        }
                    }
                    // approval
                    else if (requestOrApprovalType == "1")
                    {
                        // approved or rejected
                        if (approvalType == ((int)CConstValue.ApprovalStatus.Approved).ToString() ||
                            approvalType == ((int)CConstValue.ApprovalStatus.Rejected).ToString() ||
                            approvalType == ((int)CConstValue.ApprovalStatus.Canceled).ToString())
                        {
                            buttonList.Add("Close");
                        }
                        else
                        {
                            var refundApproveInfo = new CGlobal();
                            var supervisor        = refundApproveInfo.CheckApprovalEnable((int)CConstValue.Approval.PurchaseOrder, Convert.ToInt32(Id));

                            if (CurrentUserId == supervisor)
                            {
                                buttonList.Add("Approve");
                                buttonList.Add("Reject");
                                buttonList.Add("Revise");
                                buttonList.Add("Close");
                            }
                            else
                            {
                                buttonList.Add("Close");
                            }
                        }

                        SetVisibleItems(false);
                    }
                    // Purchase Order from HQ
                    else if (requestOrApprovalType == "2")
                    {
                        // Wating for review from HQ
                        if (approvalType == ((int)CConstValue.ApprovalStatus.WaitingForPreviewFromHq).ToString())
                        {
                            buttonList.Add("Accept");
                            buttonList.Add("Reject");
                            buttonList.Add("Close");
                        }
                        // Approved
                        else if (approvalType == ((int)CConstValue.ApprovalStatus.Approved).ToString())
                        {
                            buttonList.Add("Print");
                            buttonList.Add("Accept");
                            buttonList.Add("Close");
                        }
                        else
                        {
                            buttonList.Add("Close");
                        }

                        SetVisibleItems(false);
                    }
                }

                foreach (RadToolBarItem item in RadToolBar1.Items)
                {
                    if (buttonList.Contains(item.Text))
                    {
                        item.Visible = true;
                    }
                    else
                    {
                        item.Visible = false;
                    }
                }

                // new or temp
                if (approvalType == "0" || approvalType == string.Empty)
                {
                    FileDownloadList1.SetVisibieUploadControls(true);
                }
                else
                {
                    FileDownloadList1.SetVisibieUploadControls(false);
                }

                if (approvalType != ((int)CConstValue.ApprovalStatus.WaitingForPreviewFromHq).ToString() &&
                    approvalType != ((int)CConstValue.ApprovalStatus.Approved).ToString())
                {
                    RunClientScript("HideReview();");
                }

                var dt = new DataTable();
                dt.Columns.Add("DocNo");
                dt.Columns.Add("Site");
                dt.Columns.Add("Location");
                dt.Columns.Add("Name");
                dt.Columns.Add("Date");
                var newDr = dt.NewRow();
                newDr["DocNo"]    = obj.DocNo;
                newDr["Site"]     = obj.Site;
                newDr["Location"] = obj.Location;
                newDr["Name"]     = obj.Name;
                newDr["Date"]     = obj.Date;
                dt.Rows.Add(newDr);

                RadGridInfo.DataSource = dt;

                // New
                if (Request["createOrListType"] == "0")
                {
                    var cUser = new CUser();
                    var user  = cUser.Get(CurrentUserId);
                    if (user != null)
                    {
                        RadTextBoxShipToName.Text       = cUser.GetUserName(user);
                        RadTextBoxShipToAddress.Text    = user.Address1 + " " + user.Address2;
                        RadTextBoxShipToCity.Text       = user.City;
                        RadTextBoxShipToProvince.Text   = user.Province;
                        RadTextBoxShipToPostalCode.Text = user.PostalCode;
                        RadTextBoxShipToPhone.Text      = user.CellPhone;
                        RadTextBoxShipToEmail.Text      = user.Email;
                    }

                    // Init
                    RadNumericTextBoxShippingTerms.Value   = 1;
                    RadDatePickerDeliveryDate.SelectedDate = DateTime.Now;
                }
                else
                {
                    var result = obj.Get(Id);
                    if (result != null)
                    {
                        RadComboBoxType.SelectedIndex           = result.PurchaseOrderType;
                        RadComboBoxPriority.SelectedIndex       = (int)result.PriorityType;
                        RadComboBoxShippingMethod.SelectedIndex = (int)result.ShippingMethodType;
                        RadNumericTextBoxShippingTerms.Value    = result.ShippingTerms;
                        RadDatePickerDeliveryDate.SelectedDate  = result.ShippingDeliveryDate;
                        RadTextBoxDescription.Text = result.Description;

                        RadTextBoxVendorName.Text       = result.VendorName;
                        RadTextBoxVendorAddress.Text    = result.VendorAddress;
                        RadTextBoxVendorCity.Text       = result.VendorCity;
                        RadTextBoxVendorProvince.Text   = result.VendorProvince;
                        RadTextBoxVendorPostalCode.Text = result.VendorPostalCode;
                        RadTextBoxVendorPhone.Text      = result.VendorPhone;
                        RadTextBoxVendorEmail.Text      = result.VendorEmail;

                        RadTextBoxShipToName.Text       = result.ShipToName;
                        RadTextBoxShipToAddress.Text    = result.ShipToAddress;
                        RadTextBoxShipToCity.Text       = result.ShipToCity;
                        RadTextBoxShipToProvince.Text   = result.ShipToProvince;
                        RadTextBoxShipToPostalCode.Text = result.ShipToPostalCode;
                        RadTextBoxShipToPhone.Text      = result.ShipToPhone;
                        RadTextBoxShipToEmail.Text      = result.ShipToEmail;

                        if (result.ReviewType != null)
                        {
                            RadComboBoxReviewType.SelectedIndex = (int)result.ReviewType;
                        }
                        if (result.ReviewDate != null)
                        {
                            RadDatePickerReviewDate.SelectedDate = result.ReviewDate;
                        }
                        if (result.ReviewUserId != null)
                        {
                            var cUser = new CUser();
                            var user  = cUser.Get((int)result.ReviewUserId);
                            RadTextBoxReviewUser.Text = cUser.GetUserName(user);
                        }
                        RadDatePickerReviewDate.SelectedDate = result.ReviewDate;
                        RadTextBoxReviewMemo.Text            = result.ReviewMemo;
                        RadNumericTextBoxTax.Value           = (double)result.Tax;
                    }
                }
            }
        }