Ejemplo n.º 1
0
        // load and save data override
        public override bool SaveData(string leadID, string UserID)
        {
            bool ret = true;

            try
            {
                // prepare data
                var ins     = ctlLeadIns.GetInsData();
                var addrLst = ctlLeadIns.GetInsAddrData();


                ins.slm_ActNo             = txtActNo.Text.Trim();
                ins.slm_ActStartCoverDate = tdActStart.DateValue;
                ins.slm_ActEndCoverDate   = tdActEnd.DateValue;
                ins.slm_ActIssuePlace     = SLMUtil.SafeInt(cmbActIssue.SelectedValue);
                ins.slm_ActIssueBranch    = cmbActIssueBranch.SelectedValue;



                LeadData ldata = new LeadData();
                ldata.TicketId      = CommonData.TicketID;
                ldata.TitleId       = CommonData.TitleID;
                ldata.Name          = CommonData.FName;
                ldata.LastName      = CommonData.LName;
                ldata.ChannelId     = CommonData.ChannelID;
                ldata.CampaignId    = CommonData.CampaignID;
                ldata.TelNo_1       = CommonData.Phone1;
                ldata.TelNo_2       = CommonData.Phone2;
                ldata.Owner_Branch  = CommonData.Branch;
                ldata.Owner         = CommonData.Owner;
                ldata.IsCustomer    = ins.IsCustomer ? "Y" : "N";
                ldata.CardType      = SLMUtil.SafeInt(ins.CardType);
                ldata.CitizenId     = ins.CitizenId;
                ldata.CountryId     = ins.CountryId;
                ldata.slm_SubStatus = "15";
                ldata.Detail        = txtDetails.Text.Trim();
                if (ins.Birthdate.Year > 1)
                {
                    ldata.Birthdate = ins.Birthdate;
                }
                ldata.Occupation    = SLMUtil.SafeInt(ins.Occupation);
                ldata.TicketIdRefer = CommonData.TicketIDRefer;
                ldata.ProvinceRegis = string.IsNullOrEmpty(ins.ProvinceRegis) ? null : (int?)int.Parse(ins.ProvinceRegis);

                //owner, delegate
                ldata.HasNewOwner    = CommonData.ActOwner;
                ldata.HasNewDelegate = CommonData.ActDelegate;


                //owner
                if (CommonData.Owner != "")                 //owner lead
                {
                    ldata.Owner     = CommonData.Owner;
                    ldata.NewOwner  = CommonData.Owner;
                    ldata.NewOwner2 = CommonData.Owner;
                    StaffData StaffData = SlmScr010Biz.GetStaffData(CommonData.Owner);
                    if (StaffData != null)
                    {
                        ldata.StaffId = Convert.ToInt32(StaffData.StaffId);
                        //LData.Owner_Branch = StaffData.BranchCode;
                    }
                }

                ldata.slmOldOwner     = CommonData.OldOwner;
                ldata.OldOwner        = CommonData.OldOwner;
                ldata.OldOwner2       = CommonData.OldOwner;
                ldata.Type2           = CommonData.Type2;
                ldata.Delegate_Branch = CommonData.DelegateBranch;
                ldata.Delegate        = CommonData.DelegateLead;

                //delegate
                if (!string.IsNullOrEmpty(CommonData.DelegateFlag))
                {
                    ldata.Delegate_Flag = Convert.ToDecimal(CommonData.DelegateFlag);  //Add
                    if (ldata.Delegate_Flag == 1)
                    {
                        ldata.Delegate_Branch = CommonData.DelegateBranch;
                        ldata.Delegate        = CommonData.DelegateLead;
                        ldata.NewDelegate     = CommonData.DelegateLead;
                        ldata.OldDelegate     = CommonData.OldDelegateLead;
                        ldata.Type            = CommonData.Type;
                    }
                }
                else
                {
                    ldata.Delegate_Flag = 0;
                }

                if (string.IsNullOrEmpty(ldata.Delegate))
                {
                    ldata.Delegate_Flag = 0;
                }


                if (ldata.CardType == 0)
                {
                    ldata.CardType = null;
                }
                if (ldata.Occupation == 0)
                {
                    ldata.Occupation = null;
                }

                // get create by branch
                StaffData createbyData = SlmScr010Biz.GetStaffData(HttpContext.Current.User.Identity.Name);
                if (createbyData != null)
                {
                    ldata.CreatedBy_Branch = createbyData.BranchCode;
                }

                // saving
                string      ticketid;
                LeadInfoBiz bz = new LeadInfoBiz();
                if (!bz.SaveInsData(ldata, ins, addrLst, UserID, out ticketid, 2))
                {
                    throw new Exception(bz.ErrorMessage);
                }


                // post action
                CommonData.R_TicketID = ticketid;

                if (ldata.HasAdamsUrl)
                {
                    CommonData.R_Message  = "ต้องการแนบเอกสารต่อใช่หรือไม่?";
                    CommonData.R_HasAdams = true;
                }
                else
                {
                    CommonData.R_Message  = "ต้องการไปหน้าแสดงรายละเอียดผู้มุ่งหวังใช่หรือไม่?";
                    CommonData.R_HasAdams = false;
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Debug(message);
                ret = false;
                CommonData.R_Message = message;
            }
            return(ret);
        }