Example #1
0
        private void confirm()
        {
            DataSet resultDs;
            int     lot = 0;

            int.TryParse(Request["lot"], out lot);
            SlmScr032Biz biz = new SlmScr032Biz();

            List <SlmScr032SearchResult> successList = biz.GetSuccessList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, cmbTelesalesTeam.SelectedValue, cmbOwnerSearch.SelectedValue, out resultDs);

            List <SlmScr032SearchResult> dedupList = biz.GetDedubList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, out resultDs);

            List <SlmScr032SearchResult> blacklistList = biz.GetBlackListList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, out resultDs);

            List <SlmScr032SearchResult> exceptionalList = biz.GetExceptionalList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, out resultDs);


            if (biz.UpdateDelegateList(lot, successList, dedupList, blacklistList, exceptionalList, HttpContext.Current.User.Identity.Name.ToLower()))
            {
                AppUtil.ClientAlertAndRedirect(this, "Confirm ข้อมูลการจ่ายงานแล้ว", ResolveUrl("~/SLM_SCR_047.aspx"));
            }
            else
            {
                AppUtil.ClientAlert(this, biz.ErrorMessage);
            }
        }
Example #2
0
        private void initControl()
        {
            var cardType = CardTypeBiz.GetCardTypeList();

            cardType.Insert(0, new ControlListData()
            {
                TextField = "", ValueField = "-1"
            });
            cmbCardType.DataSource = cardType;
            cmbCardType.DataBind();

            //var campaign = CampaignBiz.GetCampaignList("01");
            var campaign = CampaignBiz.GetCampaignListNew("01");

            campaign.Insert(0, new ControlListData()
            {
                TextField = "", ValueField = "-1"
            });
            cmbCampaign.DataSource = campaign;
            cmbCampaign.DataBind();

            var saleTeam = SlmScr032Biz.GetTeamSalesList();

            saleTeam.Insert(0, new ControlListData()
            {
                TextField = "", ValueField = "-1"
            });
            cmbTelesalesTeam.DataSource = saleTeam;
            cmbTelesalesTeam.DataBind();

            txtFirstname.Text         = "";
            txtLastname.Text          = "";
            txtCitizenId.Text         = "";
            tdmTransferDate.DateValue = DateTime.MinValue;
        }
Example #3
0
 protected void cmbTelesalesTeam_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         List <ControlListData> staff = new List <ControlListData>();
         int saleTeamId = 0;
         if (cmbTelesalesTeam.SelectedValue != "-1" && int.TryParse(cmbTelesalesTeam.SelectedValue, out saleTeamId))
         {
             staff = SlmScr032Biz.GetSearchStaffList(saleTeamId);
         }
         staff.Insert(0, new ControlListData()
         {
             TextField = "", ValueField = "-1"
         });
         cmbOwnerSearch.DataSource = staff;
         cmbOwnerSearch.DataBind();
         upOwnerSearch.Update();
     }
     catch (Exception ex)
     {
         string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
         _log.Error(message);
         AppUtil.ClientAlert(Page, message);
     }
 }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    ScreenPrivilegeData priData = RoleBiz.GetScreenPrivilege(HttpContext.Current.User.Identity.Name, "SLM_SCR_032");
                    if (priData == null || priData.IsView != 1)
                    {
                        AppUtil.ClientAlertAndRedirect(Page, "คุณไม่มีสิทธิ์เข้าใช้หน้าจอนี้", "SLM_SCR_003.aspx");
                        return;
                    }

                    int lot = 0;
                    int.TryParse(Request["lot"], out lot);

                    initControl();

                    if (lot <= 0)
                    {
                        tabMain.Visible = false;
                        upNoLot.Visible = true;
                        pcNoLot_PageChange(null, null);
                        btnReject.Visible = false;
                        btnSavePopupChangeOwner.Visible = false;
                        btnExportExcel.Visible          = false;
                        btnConfirm.Visible = false;
                    }
                    else
                    {
                        SlmScr032Biz biz = new SlmScr032Biz();
                        if (!biz.CheckAccess(lot))
                        {
                            AppUtil.ClientAlertAndRedirect(Page, biz.ErrorMessage, "SLM_SCR_047.aspx");
                            return;
                        }

                        tabMain.Visible = true;
                        upNoLot.Visible = false;
                    }
                    pcSuccess_PageChange(null, null);
                    pcDedup_PageChange(null, null);
                    pcBlacklist_PageChange(null, null);
                    pcExceptional_PageChange(null, null);
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Example #5
0
        private void reject()
        {
            int lot = 0;

            int.TryParse(Request["lot"], out lot);
            SlmScr032Biz biz = new SlmScr032Biz();

            List <SlmScr032SearchResult> successList = null;// ไม่ใช้แล้ว biz.GetSuccessList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, cmbTelesalesTeam.SelectedValue, cmbOwnerSearch.SelectedValue, out resultDs);

            //Dedup==================================================================
            SaveCheckedDedup();

            List <decimal> dedupTempId       = new List <decimal>();
            var            dedup_checkedlist = DedupCheckedList;

            dedup_checkedlist.ForEach(p => {
                if (p.Value)
                {
                    dedupTempId.Add(decimal.Parse(p.Key));
                }
            });

            //Blacklist==================================================================
            SaveCheckedBlacklist();

            List <decimal> blacklistTempId = new List <decimal>();
            var            bl_checkedlist  = BlacklistCheckedList;

            bl_checkedlist.ForEach(p => {
                if (p.Value)
                {
                    blacklistTempId.Add(decimal.Parse(p.Key));
                }
            });

            List <SlmScr032SearchResult> exceptionalList = null;  //ไม่ใช่แล้ว biz.GetExceptionalList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, out resultDs);

            if (biz.RejectDelegateList(lot, successList, dedupTempId, blacklistTempId, exceptionalList, HttpContext.Current.User.Identity.Name.ToLower()))
            {
                AppUtil.ClientAlertAndRedirect(this, "Reject ข้อมูลการจ่ายงานแล้ว", ResolveUrl("~/SLM_SCR_047.aspx"));
            }
            else
            {
                AppUtil.ClientAlert(this, biz.ErrorMessage);
            }
        }
Example #6
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     //int yr = DateTime.Now.Year;
     //cmbYearStart.Items.Add(new ListItem("ทั้งหมด", "0"));
     //cmbYearEnd.Items.Add(new ListItem("ทั้งหมด", "0"));
     //for (int i = yr; i > yr-10 ;i--)
     //{
     //    cmbYearStart.Items.Add(new ListItem(i.ToString(), i.ToString()));
     //    cmbYearEnd.Items.Add(new ListItem(i.ToString(), i.ToString()));
     //}
     BuildCombo(cmbTeamCode, SlmScr032Biz.GetTeamSalesList(), "ทั้งหมด");
     BuildCombo(cmbMonthStart, new MonthBiz().GetMonthList(), "ทั้งหมด");
     BuildCombo(cmbMonthEnd, new MonthBiz().GetMonthList(), "ทั้งหมด");
     BuildCombo(cmbMonth, new MonthBiz().GetMonthList(), "ทั้งหมด");
     BuildCombo(cmbLevel, SlmScr041Biz.GetLevelData(), "ทั้งหมด");
     SetTTACombo();
 }
Example #7
0
 protected void pcNoLot_PageChange(object sender, EventArgs e)
 {
     try
     {
         DataSet resultDs;
         int     lot = 0;
         int.TryParse(Request["lot"], out lot);
         SlmScr032Biz biz         = new SlmScr032Biz();
         var          noLotResult = biz.GetNoLotList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, cmbTelesalesTeam.SelectedValue, cmbOwnerSearch.SelectedValue, out resultDs);
         BindGridview(pcNoLot, gvNoLot, noLotResult.ToArray(), pcNoLot.SelectedPageIndex);
     }
     catch (Exception ex)
     {
         string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
         _log.Error(message);
         AppUtil.ClientAlert(Page, message);
     }
 }
Example #8
0
        protected void pcBlacklist_PageChange(object sender, EventArgs e)
        {
            try
            {
                //sender = null มาจากการกดปุ่ม Search, PageLoad
                if (sender != null)
                {
                    SaveCheckedBlacklist();
                }

                DataSet resultDs;
                int     lot = 0;
                int.TryParse(Request["lot"], out lot);
                SlmScr032Biz biz             = new SlmScr032Biz();
                var          blackListResult = biz.GetBlackListList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, out resultDs);
                BindGridview(pcBlacklist, gvBlacklist, blackListResult.ToArray(), pcBlacklist.SelectedPageIndex);
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
Example #9
0
 private void SetTTACombo()
 {
     BuildCombo(cmbTTAName, SlmScr032Biz.GetSearchStaffList(SLMUtil.SafeInt(cmbTeamCode.SelectedValue)), "ทั้งหมด");
 }
Example #10
0
 private void SetStaffCombo()
 {
     AppUtil.BuildCombo(cmbTelesaleName, SlmScr032Biz.GetSearchStaffList(cmbTelesale.SelectedValue == "" ? -1 : SLMUtil.SafeInt(cmbTelesale.SelectedValue)), "ทั้งหมด");
 }
Example #11
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     AppUtil.BuildCombo(cmbTelesale, SlmScr032Biz.GetTeamSalesList(), "ทั้งหมด");
     AppUtil.BuildCombo(cmbType, SlmScr041Biz.GetLevelData(), "ทั้งหมด");
 }
Example #12
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     AppUtil.BuildCombo(cmbTeamTelesale, SlmScr032Biz.GetTeamSalesList(), "ทั้งหมด");
     AppUtil.BuildCombo(cmbIncentiveFlat, SlmScr050Biz.GetGradeDataList(), "ทั้งหมด");
 }
Example #13
0
        //protected void btnPopupDoImportExcel_Click(object sender, EventArgs e)
        //{
        //    if (fuData.HasFile)
        //    {
        //        var ext = Path.GetExtension(fuData.FileName).ToLower();
        //        if (ext != ".xls")
        //        {
        //            lblUploadError.Text = "กรุณาระบุไฟล์ให้ถูก format (xls)";
        //            return;
        //        }

        //        try
        //        {
        //            using (OleDbConnection conn = new OleDbConnection())
        //            {
        //                DataTable dt = new DataTable();
        //                string filename = Path.GetTempFileName();
        //                fuData.SaveAs(filename);
        //                //conn.ConnectionString = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES;IMEX=0;'", filename);
        //                conn.ConnectionString = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES;IMEX=1;'", filename);

        //                conn.Open();
        //                DataTable dbSchema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
        //                string firstSheetName = dbSchema.Rows[0]["TABLE_NAME"].ToString();

        //                OleDbCommand cmd = new OleDbCommand();
        //                cmd.Connection = conn;
        //                cmd.CommandType = CommandType.Text;
        //                cmd.CommandText = $"SELECT * FROM [{firstSheetName}]";

        //                using (OleDbDataAdapter adp = new OleDbDataAdapter(cmd))
        //                {
        //                    adp.Fill(dt);
        //                }

        //                List<SlmScr032SearchResult> data;
        //                SlmScr032Biz biz = new SlmScr032Biz();
        //                biz.RaiseLog += (str) =>
        //                {
        //                    if (!string.IsNullOrEmpty(str))
        //                        _log.Debug(str);
        //                };

        //                _log.Debug("Start Verify 032");
        //                if (biz.ValidateImportData(dt, out data))
        //                {
        //                    _log.Debug("Finish Verify 032");
        //                    if (tabMain.Visible)
        //                    {
        //                        decimal lot = 0;
        //                        decimal.TryParse(Request["lot"], out lot);

        //                        _log.Debug("Start Import 032");
        //                        biz.DoImport(data, HttpContext.Current.User.Identity.Name.ToLower(), lot);
        //                    }
        //                    else
        //                    {
        //                        _log.Debug("Start Do No Lot Import 032");
        //                        biz.DoNoLotImport(data, HttpContext.Current.User.Identity.Name.ToLower());
        //                    }
        //                    _log.Debug("Finish Import 032");

        //                    AppUtil.ClientAlertAndRedirect(this, "Import ข้อมูลเรียบร้อย", Request.Url.AbsoluteUri);
        //                }
        //                else
        //                {
        //                    gvUploadError.DataSource = data.Where(p => p.ErrorMessage != null && p.ErrorMessage != string.Empty).ToList();
        //                    gvUploadError.DataBind();
        //                    gvUploadError.Visible = true;
        //                    mpePopupImportExcel.Show();
        //                    upPopupImportExcel.Update();
        //                }

        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
        //            _log.Error(message);
        //            AppUtil.ClientAlert(Page, message);
        //        }
        //    }
        //    else
        //    {
        //        mpePopupImportExcel.Show();
        //    }

        //}

        protected void btnPopupDoImportExcel_Click(object sender, EventArgs e)
        {
            if (fuData.HasFile)
            {
                var ext = Path.GetExtension(fuData.FileName).ToLower();
                if (ext != ".xls")
                {
                    lblUploadError.Text = "กรุณาระบุไฟล์ให้ถูก format (xls)";
                    return;
                }

                try
                {
                    var excelData = ReadExcel();

                    List <SlmScr032SearchResult> data;
                    SlmScr032Biz biz = new SlmScr032Biz();
                    biz.RaiseLog += (str) =>
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            _log.Debug(str);
                        }
                    };

                    _log.Debug("Start Verify 032");
                    if (biz.ValidateImportData(excelData, ExcelColumnName, out data))
                    {
                        _log.Debug("Finish Verify 032");
                        if (tabMain.Visible)
                        {
                            decimal lot = 0;
                            decimal.TryParse(Request["lot"], out lot);

                            _log.Debug("Start Import 032");
                            biz.DoImport(data, HttpContext.Current.User.Identity.Name.ToLower(), lot);
                        }
                        else
                        {
                            _log.Debug("Start Do No Lot Import 032");
                            biz.DoNoLotImport(data, HttpContext.Current.User.Identity.Name.ToLower());
                        }
                        _log.Debug("Finish Import 032");

                        AppUtil.ClientAlertAndRedirect(this, "Import ข้อมูลเรียบร้อย", Request.Url.AbsoluteUri);
                    }
                    else
                    {
                        gvUploadError.DataSource = data.Where(p => p.ErrorMessage != null && p.ErrorMessage != string.Empty).ToList();
                        gvUploadError.DataBind();
                        gvUploadError.Visible = true;
                        mpePopupImportExcel.Show();
                        upPopupImportExcel.Update();
                    }
                }
                catch (Exception ex)
                {
                    string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                    _log.Error(message);
                    AppUtil.ClientAlert(Page, message);
                }
            }
            else
            {
                mpePopupImportExcel.Show();
            }
        }
Example #14
0
        protected void btnExportExcel_Click(object sender, EventArgs e)
        {
            try
            {
                DataSet resultDs;
                int     lot = 0;
                int.TryParse(Request["lot"], out lot);
                SlmScr032Biz biz            = new SlmScr032Biz();
                string       date           = DateTime.Now.Year.ToString() + DateTime.Now.ToString("MMddHHmmss");
                string       filename       = "";
                string       outputFilename = "";
                bool         doExport       = false;

                switch (tabMain.ActiveTabIndex)
                {
                case 0:     // tab success
                    var successList = biz.GetSuccessList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, cmbTelesalesTeam.SelectedValue, cmbOwnerSearch.SelectedValue, out resultDs);
                    //if (resultDs.Tables[0].Rows.Count > 0)
                    if (successList.Count > 0)
                    {
                        filename = Path.Combine(Path.GetTempPath(), Page.User.Identity.Name + "_" + date + ".xls");
                        biz.CreateExcel(successList, filename, "success", "jobDelegateSuccessTab");
                        outputFilename = "jobDelegateSuccessTab.xls";
                        doExport       = true;
                    }
                    break;

                case 1:     // tab dedup
                    var dedubList = biz.GetDedubList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, out resultDs);
                    if (dedubList.Count > 0)
                    {
                        filename = Path.Combine(Path.GetTempPath(), Page.User.Identity.Name + "_" + date + ".xls");
                        biz.CreateExcel(dedubList, filename, "dedup", "jobDelegateDedupTab");
                        outputFilename = "jobDelegateDedupTab.xls";
                        doExport       = true;
                    }
                    break;

                case 2:     // tab blacklist
                    var blacklistList = biz.GetBlackListList(lot, txtFirstname.Text.Trim(), txtLastname.Text.Trim(), cmbCardType.SelectedValue, txtCitizenId.Text.Trim(), cmbCampaign.SelectedValue, tdmTransferDate.DateValue, out resultDs);
                    if (blacklistList.Count > 0)
                    {
                        filename = Path.Combine(Path.GetTempPath(), Page.User.Identity.Name + "_" + date + ".xls");
                        biz.CreateExcel(blacklistList, filename, "blacklist", "jobDelegateBlacklistTab");
                        outputFilename = "jobDelegateBlacklistTab.xls";
                        doExport       = true;
                    }
                    break;

                case 3: break;     // not allow to export tab Exceptional

                default: break;
                }

                if (doExport)
                {
                    Session["excelfilepath"]  = filename;
                    Session["outputfilename"] = outputFilename;

                    string script = "window.open('SLM_SCR_045.aspx', 'exporttab', 'status=yes, toolbar=no, scrollbars=no, menubar=no, width=300, height=100, resizable=yes');";
                    ScriptManager.RegisterStartupScript(Page, GetType(), "exporttab", script, true);
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Error(message);
                AppUtil.ClientAlert(Page, message);
            }
        }