示例#1
0
        protected void btnSavePopup_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtStaffId.Text.Trim() == "")
                {
                    AppUtil.ClientAlert(Page, "กรุณาระบุพนักงานที่ต้องการโอนงาน Owner");
                    mpePopupTransfer.Show();
                    return;
                }
                else if (cmbBranchCode.SelectedItem.Value == "")
                {
                    AppUtil.ClientAlert(Page, "ไม่สามารถโอนงานได้ เนื่องจากไม่มีข้อมูลสาขาของพนักงานที่ต้องการโอนงาน");
                    mpePopupTransfer.Show();
                    return;
                }
                else if (rbnUserTypeGroup.Checked == true)
                {
                    AppUtil.ClientAlert(Page, "ไม่สามารถโอนงานได้ เนื่องจากเป็น ประเภท User Group(Dummy)");
                    mpePopupTransfer.Show();
                    return;
                }
                else
                {
                    if (gvOwner.Rows.Count > 0)
                    {
                        List <string> ticketlist  = new List <string>();
                        List <string> notPassList = new List <string>();

                        for (int i = 0; i < gvOwner.Rows.Count; i++)
                        {
                            CheckBox cbSelect = (CheckBox)gvOwner.Rows[i].FindControl("cbSelect");
                            if (cbSelect != null && cbSelect.Checked == true)
                            {
                                //Check Access Right
                                string ticketId   = ((Label)gvOwner.Rows[i].FindControl("lbTicketId")).Text.Trim();
                                string campaignId = ((Label)gvOwner.Rows[i].FindControl("lblCampaignId")).Text.Trim();

                                if (!SlmScr010Biz.PassPrivilegeCampaign(SLMConstant.Branch.Active, campaignId, txtUsernamePopup.Text.Trim()))
                                {
                                    notPassList.Add(ticketId);
                                }
                                else
                                {
                                    ticketlist.Add(ticketId);
                                }
                            }
                        }

                        SlmScr018Biz.UpdateTransferOwnerLead(ticketlist, txtUsernamePopup.Text.Trim(), int.Parse(txtStaffId.Text.Trim()), HttpContext.Current.User.Identity.Name, cmbBranchCode.SelectedItem.Value, txtusername.Text.Trim());

                        txtEmpCodePopup.Text       = "";
                        txtStaffId.Text            = "";
                        txtUsernamePopup.Text      = "";
                        txtMarketingCode.Text      = "";
                        txtStaffNameTH.Text        = "";
                        txtTellNo.Text             = "";
                        txtStaffEmail.Text         = "";
                        cmbPosition.SelectedIndex  = -1;
                        cmbStaffType.SelectedIndex = -1;
                        txtTeam.Text = "";
                        cmbBranchCode.SelectedIndex     = -1;
                        cmbHeadBranchCode.SelectedIndex = -1;
                        cmbHeadBranchCode_SelectedIndexChanged();
                        cmbHeadStaffId.SelectedIndex = -1;
                        cmbDepartment.SelectedIndex  = -1;
                        rdNormal.Checked             = false;
                        rdRetire.Checked             = false;
                        GetOwnerList();
                        upResult.Update();

                        //if (UpdatedDataChanged != null) UpdatedDataChanged("tabDelegate");

                        string alertTicketIdList = "";
                        foreach (string ticketId in notPassList)
                        {
                            alertTicketIdList += (alertTicketIdList != "" ? ", " : "") + ticketId;
                        }

                        if (alertTicketIdList == "")
                        {
                            AppUtil.ClientAlert(Page, "บันทึกข้อมูลเรียบร้อยแล้ว");
                        }
                        else
                        {
                            AppUtil.ClientAlert(Page, "บันทึกข้อมูลเรียบร้อยแล้ว โดยมี Ticket Id ที่โอนไม่ได้ดังนี้" + Environment.NewLine + alertTicketIdList);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                AppUtil.ClientAlert(Page, message);
                mpePopupTransfer.Show();
            }
        }
示例#2
0
        public bool ValidateData(bool isValidateNewLead = true)
        {
            if (!isValidateNewLead)     //หน้า Edit
            {
                if (!IsLastestOwnerDelegate())
                {
                    AppUtil.ClientAlertAndRedirect(Page, "ข้อมูลผู้มุ่งหวังนี้ถูกจ่ายงานให้พนักงานท่านอื่นแล้ว ระบบจะทำการ Refresh หน้าจอให้", "SLM_SCR_011.aspx?ticketid=" + txtslm_TicketId.Text.Trim());
                    return(false);
                }
            }

            int i = 0;

            if (txtName.Text.Trim() == string.Empty)
            {
                vtxtName.Text = "กรุณาระบุชื่อ";
                i            += 1;
            }
            else
            {
                vtxtName.Text = "";
            }

            if (cmbCampaignId.SelectedItem.Value == string.Empty)
            {
                vcmbCampaignId.Text = "กรุณาระบุแคมเปญ";
                i += 1;
            }
            else
            {
                vcmbCampaignId.Text = "";
            }

            if (cmbChannelId.SelectedItem.Value == string.Empty)
            {
                vcmbChannelId.Text = "กรุณาระบุช่องทาง";
                i += 1;
            }
            else
            {
                vcmbChannelId.Text = "";
            }
            //****************************Owner**********************************************************
            if (isValidateNewLead)
            {
                if (cmbOwnerBranch.SelectedItem.Value != string.Empty && cmbOwner.Items.Count > 0 && cmbOwner.SelectedItem.Value == string.Empty)
                {
                    vcmbOwner.Text = "กรุณาระบุ Owner Lead";
                    i += 1;
                }
                else
                {
                    vcmbOwner.Text = "";
                    if (cmbCampaignId.SelectedItem.Value != string.Empty && cmbOwnerBranch.SelectedItem.Value != string.Empty && cmbOwner.Items.Count > 0 && cmbOwner.SelectedItem.Value != string.Empty)
                    {
                        if (!SlmScr010Biz.PassPrivilegeCampaign(SLMConstant.Branch.Active, cmbCampaignId.SelectedItem.Value, cmbOwner.SelectedItem.Value))
                        {
                            vcmbOwner.Text = "Owner Lead ไม่มีสิทธิ์ในแคมเปญนี้";
                            i += 1;
                        }
                        else
                        {
                            vcmbOwner.Text = "";
                        }
                    }
                }
            }
            else
            {
                //หน้า Edit
                //OwnerBranch, Owner
                string clearOwnerBranchText = "Y";
                if (!AppUtil.ValidateOwner(newassignflag, cmbOwnerBranch, vcmbOwnerBranch, cmbOwner, vcmbOwner, cmbCampaignId.SelectedItem.Value, ref clearOwnerBranchText))
                {
                    i += 1;
                }

                //Branch ที่ถูกปิด
                if (cmbOwnerBranch.Items.Count > 0 && cmbOwnerBranch.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbOwnerBranch.SelectedItem.Value))
                {
                    vcmbOwnerBranch.Text = "สาขานี้ถูกปิดแล้ว";
                    i += 1;
                }
                else
                {
                    if (clearOwnerBranchText == "Y")
                    {
                        vcmbOwnerBranch.Text = "";
                    }
                }
            }


            //****************************Delegate**********************************************************
            //Delegate มีเฉพาะหน้า Edit
            if (!isValidateNewLead)
            {
                if (cmbDelegateBranch.Items.Count > 0 && cmbDelegateBranch.SelectedItem.Value != "" && !BranchBiz.CheckBranchActive(cmbDelegateBranch.SelectedItem.Value))
                {
                    vcmbDelegateBranch.Text = "สาขานี้ถูกปิดแล้ว";
                    i += 1;
                }
                else
                {
                    vcmbDelegateBranch.Text = "";
                }

                if (cmbDelegateBranch.SelectedItem.Value != string.Empty && cmbDelegateLead.SelectedItem.Value == string.Empty)
                {
                    vcmbDelegateLead.Text = "กรุณาระบุ Delegate Lead";
                    i += 1;
                }
                else
                {
                    vcmbDelegateLead.Text = "";
                }
            }

            //****************************หมายเลขโทรศัพท์ 1********************************************
            decimal result1;

            if (txtTelNo_1.Text.Trim() == string.Empty)
            {
                vtxtTelNo_1.Text = "กรุณาระบุหมายเลขโทรศัพท์ 1(มือถือ)ให้ถูกต้อง";
                i += 1;
            }
            else if (txtTelNo_1.Text.Trim().Length < 9 || txtTelNo_1.Text.Trim().Length > 10)
            {
                vtxtTelNo_1.Text = "กรุณาระบุหมายเลขโทรศัพท์ 1(มือถือ)ให้ถูกต้อง";
                i += 1;
            }
            else if (txtTelNo_1.Text.Trim() != string.Empty && !decimal.TryParse(txtTelNo_1.Text.Trim(), out result1))
            {
                vtxtTelNo_1.Text = "หมายเลขโทรศัพท์ 1(มือถือ)ต้องเป็นตัวเลขเท่านั้น";
                i += 1;
            }
            else if (txtTelNo_1.Text.Trim().StartsWith("0") == false)
            {
                vtxtTelNo_1.Text = "หมายเลขโทรศัพท์ 1(มือถือ)ต้องขึ้นต้นด้วยเลข 0 เท่านั้น";
                i += 1;
            }
            else
            {
                vtxtTelNo_1.Text = "";
            }

            //****************************หมายเลขโทรศัพท์ 2********************************************
            decimal result2;

            if (txtTelNo2.Text.Trim() != string.Empty && txtTelNo2.Text.Trim().Length < 9)
            {
                vtxtTelNo2.Text = "หมายเลขโทรศัพท์ 2 ต้องมีอย่างน้อย 9 หลัก";
                i += 1;
            }
            else if (txtTelNo2.Text.Trim() != string.Empty && !decimal.TryParse(txtTelNo2.Text.Trim(), out result2))
            {
                vtxtTelNo2.Text = "หมายเลขโทรศัพท์ 2 ต้องเป็นตัวเลขเท่านั้น";
                i += 1;
            }
            else if (txtTelNo2.Text.Trim() != string.Empty && txtTelNo2.Text.Trim().StartsWith("0") == false)
            {
                vtxtTelNo2.Text = "หมายเลขโทรศัพท์ 2 ต้องขึ้นต้นด้วยเลข 0 เท่านั้น";
                i += 1;
            }
            else
            {
                vtxtTelNo2.Text = "";
            }
            //****************************หมายเลขโทรศัพท์ 3********************************************

            //****************************Ticket ID Refer********************************************
            SlmScr003Biz biz = new SlmScr003Biz();

            if (txtTicketIdRefer.Text.Trim() != string.Empty && txtslm_TicketId.Text == txtTicketIdRefer.Text.Trim())
            {
                vtxtTicketIdRefer.Text = "Ticket ID Refer ต้องไม่เท่ากับ Ticket ID";
                i += 1;
            }
            else if (SlmScr003Biz.ValidateTicketIDRefer(txtTicketIdRefer.Text.Trim()))
            {
                vtxtTicketIdRefer.Text = "ไม่พบ Ticket ID Refer ที่ระบุ";
                i += 1;
            }
            //ValidateTicketIDRefer

            return(i == 0);
        }