protected void imbEditCampaign_Click(object sender, EventArgs e)
        {
            try
            {
                cmbCampaignCode.DataSource     = RankingCampaignBiz.GetCampaignMasterList(); //C=Customer
                cmbCampaignCode.DataTextField  = "slm_CampaignCode";
                cmbCampaignCode.DataValueField = "slm_CampaignCode";
                cmbCampaignCode.DataBind();
                cmbCampaignCode.Items.Insert(0, new ListItem("", ""));

                cmbCampaignName.DataSource     = RankingCampaignBiz.GetCampaignMasterList(); //C=Customer
                cmbCampaignName.DataTextField  = "slm_CampaignName";
                cmbCampaignName.DataValueField = "slm_CampaignCode";
                cmbCampaignName.DataBind();
                cmbCampaignName.Items.Insert(0, new ListItem("", ""));

                decimal RankingCampaignId = decimal.Parse(((ImageButton)sender).CommandArgument);

                List <RankingCampaignData> rcs = (List <RankingCampaignData>)ViewState["Campaign"];
                RankingCampaignData        rc  = rcs.Where(r => r.coc_RankingCampaignId == RankingCampaignId).FirstOrDefault();

                cmbCampaignCode.SelectedValue = rc.coc_CampaignCode;
                cmbCampaignName.SelectedValue = rc.coc_CampaignCode;

                mpePopupAddCampaign.Show();
                upPopupAddCampaign.Update();
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Debug(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
        protected void btnSavePopupAddCampaign_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidatePopupAddCampaign())
                {
                    //RankingCampaignBiz biz = new RankingCampaignBiz();
                    //if (biz.ValidateData(AppUtil.SafeInt(hidRankingId.Value), cmbCampaignCode.SelectedItem.Value))
                    //{
                    //biz.InsertData(AppUtil.SafeInt(hidRankingId.Value), cmbCampaignCode.SelectedItem.Value, cmbCampaignName.SelectedItem.Value, HttpContext.Current.User.Identity.Name.ToLower());


                    RankingCampaignData rc = new RankingCampaignData();
                    rc.coc_RankingId    = AppUtil.SafeInt(hidRankingId.Value);
                    rc.coc_CampaignCode = cmbCampaignCode.SelectedItem.Text;
                    rc.coc_CampaignName = cmbCampaignName.SelectedItem.Text;

                    List <RankingCampaignData> RankingCampaigns;

                    if (ViewState["Campaign"] != null)
                    {
                        RankingCampaigns = (List <RankingCampaignData>)ViewState["Campaign"];
                    }
                    else
                    {
                        RankingCampaigns = new List <RankingCampaignData>();
                    }

                    //if (ValidatePopupAddCampaign())
                    //{
                    RankingCampaigns.Add(rc);
                    //}
                    ViewState["Campaign"] = RankingCampaigns;
                    ClearPopupAddCampaign();
                    mpePopupAddCampaign.Hide();

                    DoSearchCampaign(0);
                    AppUtil.ClientAlert(Page, "บันทึกข้อมูลเรียบร้อย");
                    //}
                    //else
                    //{
                    //    AppUtil.ClientAlert(Page, biz.ErrorMessage);
                    //    mpePopupAddCampaign.Show();
                    //}
                }
                else
                {
                    mpePopupAddCampaign.Show();
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Debug(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
 protected void imbDeleteCampaign_Click(object sender, EventArgs e)
 {
     try
     {
         decimal RankingCampaignId = decimal.Parse(((ImageButton)sender).CommandArgument);
         //new RankingCampaignBiz().DeleteData(RankingCampaignId);
         List <RankingCampaignData> rcs = (List <RankingCampaignData>)ViewState["Campaign"];
         RankingCampaignData        rc  = rcs.Where(r => r.coc_RankingCampaignId == RankingCampaignId).FirstOrDefault();
         rcs.Remove(rc);
         DoSearchCampaign(0);
         AppUtil.ClientAlert(Page, "ลบข้อมูลเรียบร้อย");
     }
     catch (Exception ex)
     {
         string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
         _log.Debug(message);
         AppUtil.ClientAlert(Page, message);
     }
 }