public ActionResult Delete(long id)
        {
            string     username = User.Identity.GetUserName();
            CommonView model    = new CommonView();

            try
            {
                _campaignService.Deactivate(id, username);
                _siteCampaignService.Deactivate(id);
                model.Message = "Data deleted.";
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(ArgumentException))
                {
                    model.Message = ((ArgumentException)ex).Message;
                }
                else
                {
                    model.Message = "Unable to delete data. Please contact your system administrator.";
                }
            }

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
 public RandomizeView()
 {
     InitializeComponent();
     CommonView.HideAllButton();
     TakeAllCheckbox.IsChecked = true;
     TakeAllCheckbox_OnClick(TakeAllCheckbox, new RoutedEventArgs(MouseUpEvent));
 }
Esempio n. 3
0
 public MainWindow()
 {
     InitializeComponent();
     ViewsGrid.Children.Clear();
     _commonView = (CommonView)DataContext;
     _commonView.Computations.ForEach(computation => AddView((ICalculationViewModel)computation.View));
 }
        public ActionResult Save(CampaignViewModel data)
        {
            string     username = User.Identity.GetUserName();
            CommonView model    = new CommonView();
            string     message  = string.Empty;

            try
            {
                if (data.ID == 0)
                {
                    CampaignViewModel campaign = new CampaignViewModel();
                    //add
                    data.CreatedBy   = username;
                    data.DateCreated = DateTime.Now;
                    data.SiteID      = 0;

                    campaign = _campaignService.Create(data);
                    if (campaign.ID > 0)
                    {
                        message = "Data added.";
                        data.ID = campaign.ID;
                    }
                }
                else
                {
                    //update
                    data.DateModified = DateTime.Now;
                    data.ModifiedBy   = username;
                    data.SiteID       = 0;

                    _campaignService.Update(data);

                    message = "Data updated.";
                }

                _siteCampaignService.Create(data.ID, data.SiteIDs);

                model.Message = message;
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(ArgumentException))
                {
                    model.Message = ((ArgumentException)ex).Message;
                }
                else
                {
                    model.Message = "Unable to save data. Please contact your system administrator.";
                }
            }


            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Save(DynamicFormulaView data)
        {
            string     username = User.Identity.GetUserName();
            CommonView model    = new CommonView();
            string     message  = string.Empty;

            try
            {
                var sclf = new SiteCampaignLobFormulaViewModel()
                {
                    ID               = data.ID,
                    SiteID           = data.SiteID,
                    CampaignID       = data.CampaignID,
                    LoBID            = data.LobID,
                    DynamicFormulaID = data.FormulaID,
                    Active           = true
                };

                if (data.ID == 0)
                {
                    _siteCampaignLobFormulaService.Create(sclf);
                    if (sclf.ID > 0)
                    {
                        message = "Data added.";
                        data.ID = sclf.ID;
                    }
                }
                else
                {
                    //update
                    _siteCampaignLobFormulaService.Update(sclf);

                    message = "Data updated.";
                }

                model.Message = message;
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(ArgumentException))
                {
                    model.Message = ((ArgumentException)ex).Message;
                }
                else
                {
                    model.Message = "Unable to save data. Please contact your system administrator.";
                }
            }

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    SearchOrderDetailArgs args = new SearchOrderDetailArgs();
                    args.OrderBy = "[OrderID]";
                    args.Barcode = this.txtBarcode.Text;
                    //args.OrderStatus = "P";
                    SearchResult sr = p.Client.SearchOrderDetail(CGlobal.SenderUser, args);

                    if (sr.DataSet.Tables[0].Rows.Count > 0)
                    {
                        sr.DataSet.Tables[0].Columns.Add(new DataColumn("BarcodeImg", typeof(byte[])));
                        sr.DataSet.Tables[0].Columns.Add(new DataColumn("TotalBattchQty", typeof(Int32)));
                        sr.DataSet.Tables[0].Columns.Add(new DataColumn("TotalOrderQty", typeof(Int32)));
                        sr.DataSet.Tables[0].Rows[0]["BarcodeImg"]     = CommonView.getQRcode(sr.DataSet.Tables[0].Rows[0]["BarcodeNo"].ToString());
                        sr.DataSet.Tables[0].Rows[0]["TotalOrderQty"]  = 10;
                        sr.DataSet.Tables[0].Rows[0]["TotalBattchQty"] = 10;
                    }
                    else
                    {
                        throw new Exception("条码不存在。");
                    }

                    this.rptView.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
                    this.rptView.LocalReport.DataSources.Clear();
                    sr.DataSet.DataSetName = "DataSet1";
                    ReportDataSource rptDataSource = new ReportDataSource();
                    rptDataSource.Name  = "DataSet1";
                    rptDataSource.Value = sr.DataSet.Tables[0];

                    //YK170300007
                    LocalReport report = new LocalReport();
                    report.DataSources.Clear();
                    //设置需要打印的报表的文件名称。
                    report.ReportEmbeddedResource = "Mes.Package.Report.rptBoardLabel.rdlc";
                    report.DataSources.Add(rptDataSource);
                    //刷新报表中的需要呈现的数据
                    report.Refresh();

                    this.rptView.LocalReport.DataSources.Add(rptDataSource);
                    this.rptView.RefreshReport();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 7
0
    public bool Initialize()
    {
        IRegion tabRegion = _shellRegionManager.Regions["tabRegion"];
        //You may actually want to use your container to resolve the common view, but
        //I'm creating it here for demonstration sake.
        Object commonView = new CommonView();

        //This is the important part... setting the 3rd parameter to true gives us
        //a new locally scoped region manager, so Prism won't complain about the fact
        //that the common view contains regions with names that have already been
        //registered in other modules
        IRegionManager localRM = tabRegion.Add(new CommonView, "ModuleACommon", true);

        IRegion commonContentRegion = localRM.Regions["ContentRegion"];

        commonContentRegion.Add(new ModuleAView());
    }
Esempio n. 8
0
        public ActionResult Save(SiteViewModel data)
        {
            string     username = User.Identity.GetUserName();
            CommonView model    = new CommonView();

            try
            {
                if (data.ID == 0)
                {
                    SiteViewModel site = new SiteViewModel();
                    //add
                    data.CreatedBy   = username;
                    data.DateCreated = DateTime.Now;

                    site = _siteService.Create(data);
                    if (site.ID > 0)
                    {
                        model.Message = "Data added.";
                    }
                }
                else
                {
                    //update
                    data.DateModified = DateTime.Now;
                    data.ModifiedBy   = username;

                    _siteService.Update(data);

                    model.Message = "Data updated.";
                }
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(ArgumentException))
                {
                    model.Message = ((ArgumentException)ex).Message;
                }
                else
                {
                    model.Message = "Unable to save data. Please contact your system administrator.";
                }
            }


            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Esempio n. 9
0
        public string EditTask(CommonView commonView)
        {
            var AssginerID = from item in db.Users
                             where item.UserName == commonView.SelectedAssigner
                             select item.UserID;
            var AssgineeID = from item in db.Users
                             where item.UserName == commonView.SelectedAssignee
                             select item.UserID;
            var StatusID = from item in db.Status
                           where item.StatusName == commonView.SelectedStatus
                           select item.StatusID;
            var PriorityID = from item in db.TaskPriorities
                             where item.PriorityName == commonView.SelectedPriority
                             select item.PriorityID;

            db.usp_UpdateTasks(commonView.TaskID, commonView.TaskName, commonView.AssignedDate, commonView.DueDate, StatusID.FirstOrDefault(), PriorityID.FirstOrDefault(), AssgineeID.FirstOrDefault(), AssginerID.FirstOrDefault());
            db.SaveChanges();
            return("success");
        }
Esempio n. 10
0
        // GET: Task
        public ActionResult TaskList()
        {
            httpClient.BaseAddress = new Uri("http://localhost:49982");
            httpClient.DefaultRequestHeaders.Accept.
            Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = httpClient.GetAsync("api/Tasks/GetTasks").Result;

            if (response.IsSuccessStatusCode)
            {
                tasks = response.Content.ReadAsAsync <IEnumerable <TaskView> >().Result;
            }
            HttpResponseMessage Status = httpClient.GetAsync("api/Tasks/GetStatusList").Result;

            if (Status.IsSuccessStatusCode)
            {
                statusLists = Status.Content.ReadAsAsync <IEnumerable <StatusList> >().Result;
            }
            HttpResponseMessage Priority = httpClient.GetAsync("api/Tasks/GetPriorityList").Result;

            if (Priority.IsSuccessStatusCode)
            {
                priorityLists = Priority.Content.ReadAsAsync <IEnumerable <PriorityList> >().Result;
            }

            HttpResponseMessage Assignee = httpClient.GetAsync("api/Tasks/GetAssigneeList").Result;

            if (Assignee.IsSuccessStatusCode)
            {
                AssigneeLists = Assignee.Content.ReadAsAsync <IEnumerable <Users> >().Result;
            }
            CommonView commonView = new CommonView();

            commonView.Status   = statusLists.ToList();
            commonView.Priority = priorityLists.ToList();
            commonView.TaskView = tasks.ToList();
            commonView.Users    = AssigneeLists.ToList();
            return(View(commonView));
        }
Esempio n. 11
0
        void OrderView_FBBasePageLoaded(object sender, EventArgs e)
        {
            string typeName = this.Type;

            if (typeName == "AuditOrder")
            {
                AuditOrder ao = new AuditOrder();
                ao.OrderType = typeName;
                ao.InitForm();
                this.LayoutRoot.Children.Add(ao);
                currentPart = ao as IWebPart;
            }
            else
            {
                CommonView  commonView  = new CommonView();
                Type        type        = CommonFunction.GetType(typeName, CommonFunction.TypeCategory.EntityObject);
                OrderEntity orderEntity = new OrderEntity(type);
                commonView.DefaultEntity = orderEntity;
                commonView.InitForm();
                this.LayoutRoot.Children.Add(commonView);
                currentPart = commonView as IWebPart;
            }
        }
Esempio n. 12
0
 public GenerateAlphanumericView()
 {
     InitializeComponent();
     CommonView.HideAllButton();
     LowerCheckbox.IsChecked = true;
 }
Esempio n. 13
0
 public ChangeCaseView()
 {
     InitializeComponent();
     CommonView.HideAllButton();
     TitlecaseRadio.IsChecked = true;
 }
Esempio n. 14
0
 public DirListView()
 {
     InitializeComponent();
     CommonView.HideAllButton();
     BothRadio.IsChecked = true;
 }
Esempio n. 15
0
 public ZipFilesView()
 {
     InitializeComponent();
     CommonView.HideAllButton();
 }
        public ActionResult Save_09252017(LoBViewModel data)
        {
            string     username = User.Identity.GetUserName();
            CommonView model    = new CommonView();
            string     message  = string.Empty;

            try
            {
                foreach (var siteCampaignID in data.SiteCampaignIds.TrimEnd(',').Split(','))
                {
                    long id = Convert.ToInt64(siteCampaignID);
                    //check if lobname exists
                    var siteCampaign = _siteCampaignService.Get(id, true);

                    long siteid     = 0;
                    long campaignid = 0;
                    long lobid      = 0;

                    #region Create/Update
                    if (siteCampaign != null)
                    {
                        var count = _siteCampaignLobService.Count(null,
                                                                  siteCampaign.CampaignID,
                                                                  data.Name,
                                                                  true);


                        #region
                        siteid     = siteCampaign.SiteID;
                        campaignid = siteCampaign.CampaignID;
                        if (count == 0)
                        {
                            //create LOB
                            data.DateCreated = DateTime.Now;
                            data.CreatedBy   = username;
                            var lob = this.Create(data, siteCampaign);
                            lobid = lob.ID;
                        }
                        else if (count > 0)
                        {
                            //exists
                            data.DateModified = DateTime.Now;
                            data.ModifiedBy   = username;

                            //get lob
                            var lob = _siteCampaignLobService.GetAll().Where(x => x.CampaignID == siteCampaign.CampaignID && x.LobVM.Name == data.Name)
                                      .Select(x => x.LobVM).FirstOrDefault();
                            //_lobService.GetAll().Where( x => x.Name == data.Name && x.Active == true ).FirstOrDefault();
                            //check sitecampaignlob
                            count =
                                _siteCampaignLobService.GetAll().Where(x => x.CampaignID == siteCampaign.CampaignID &&
                                                                       x.LobID == lob.ID &&
                                                                       x.Active == true && x.LobVM.Active == true).Count();

                            lobid = lob.ID;
                            if (count > 0)
                            {
                                //update
                                _lobService.Update(data);
                                //create sitecampaignlob
                                _siteCampaignLobService.Create(lob.ID, siteCampaign.SiteID, siteCampaign.CampaignID);
                            }
                            else if (count == 0)
                            {
                                //create lob and sitecampaignlob
                                this.Create(data, siteCampaign);
                            }
                        }


                        #endregion
                        message = "Lob Saved.";
                    }
                    #endregion

                    //Check if site campaign lob  have weeklyahdatapoin,weeklystaffdatapoint,weeklyhiringdatapoin
                    //      create those data.
                    if (siteid > 0 && campaignid > 0 && lobid > 0)
                    {
                        _lobService.CreateWeeklyDatapoints(siteid, campaignid, lobid);
                    }
                }

                model.Message = message;
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(ArgumentException))
                {
                    model.Message = ((ArgumentException)ex).Message;
                }
                else
                {
                    model.Message = "Unable to save data. Please contact your system administrator.";
                }
            }


            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Esempio n. 17
0
        /// <summary>
        /// 打印预览
        /// </summary>
        /// <param name="sourceData"></param>
        /// <param name="LogoFile"></param>
        /// <returns></returns>
        public DataSet GetItemLabelDataSource(DataTable sourceData, string LogoFile)
        {
            DataSet ds = new DataSet("tbPackageDataTable");

            using (ProxyBE p = new ProxyBE())
            {
                #region 70*200的条码

                DataTable tb = new DataTable();
                tb.Columns.Add(new DataColumn("OrderNo", typeof(string)));
                tb.Columns.Add(new DataColumn("OutOrderNo", typeof(string)));
                tb.Columns.Add(new DataColumn("PurchaseNo", typeof(string)));
                tb.Columns.Add(new DataColumn("CustomerName", typeof(string)));
                tb.Columns.Add(new DataColumn("Address", typeof(string)));
                tb.Columns.Add(new DataColumn("LinkMan", typeof(string)));
                tb.Columns.Add(new DataColumn("Mobile", typeof(string)));
                //tb.Columns.Add(new DataColumn("ItemName", typeof(string)));
                tb.Columns.Add(new DataColumn("CabinetName", typeof(string)));
                tb.Columns.Add(new DataColumn("MaterialStyle", typeof(string)));
                tb.Columns.Add(new DataColumn("Size", typeof(string)));
                tb.Columns.Add(new DataColumn("Color", typeof(string)));
                tb.Columns.Add(new DataColumn("PackageNum", typeof(string)));
                tb.Columns.Add(new DataColumn("TotalPackage", typeof(string)));
                tb.Columns.Add(new DataColumn("PackageBarcode", typeof(string)));
                tb.Columns.Add(new DataColumn("ItemName_1", typeof(string)));
                tb.Columns.Add(new DataColumn("ItemName_2", typeof(string)));
                tb.Columns.Add(new DataColumn("ItemName_3", typeof(string)));
                tb.Columns.Add(new DataColumn("Barcode", typeof(byte[])));
                tb.Columns.Add(new DataColumn("Logo", typeof(byte[])));
                tb.Columns.Add(new DataColumn("PrintDate", typeof(string)));
                tb.Columns.Add(new DataColumn("PackageDesc", typeof(string)));
                tb.Columns.Add(new DataColumn("ItemsQty", typeof(Int32)));


                //重置报表数据列
                foreach (DataRow row in sourceData.Rows)
                {
                    SearchPackageDetailArgs subArgs = new SearchPackageDetailArgs();
                    subArgs.OrderID   = (Guid)row["OrderID"];
                    subArgs.PackageID = (Guid)row["PackageID"];

                    //包装明细
                    SearchResult subResult = p.Client.SearchPackageDetail(CGlobal.SenderUser, subArgs);

                    var query = from g in subResult.DataSet.Tables[0].AsEnumerable()
                                group g by new
                    {
                        PackageNum     = g.Field <int>("PackageNum"),
                        PackageBarcode = g.Field <string>("PackageBarcode"),
                        ItemName       = g.Field <string>("ItemName"),
                        MadeLength     = g.Field <decimal>("MadeLength"),
                        MadeWidth      = g.Field <decimal>("MadeWidth"),
                        MadeHeight     = g.Field <decimal>("MadeHeight")
                    } into lists_Package
                        select new
                    {
                        ItemName       = lists_Package.Key.ItemName,
                        PackageBarcode = lists_Package.Key.PackageBarcode,
                        PackageNum     = lists_Package.Key.PackageNum,
                        MadeWidth      = lists_Package.Key.MadeWidth,
                        MadeLength     = lists_Package.Key.MadeLength,
                        MadeHeight     = lists_Package.Key.MadeHeight,
                        Qty            = lists_Package.Sum(n => n.Field <int>("Qty"))
                    };


                    var lists    = query.ToList();
                    int rows     = lists.Count / 3 + (lists.Count % 3 > 0 ? 1 : 0);//如果list.count为5行,则rows为2
                    int totalQty = lists.Sum(li => li.Qty);

                    //生产行数据
                    for (int i = 0; i < rows; i++)
                    {
                        DataRow newRow = tb.NewRow();
                        newRow["OrderNo"]        = row["OrderNo"];
                        newRow["OutOrderNo"]     = row["OutOrderNo"];
                        newRow["PurchaseNo"]     = row["PurchaseNo"];
                        newRow["CustomerName"]   = row["CustomerName"];
                        newRow["Address"]        = row["Address"];
                        newRow["LinkMan"]        = row["LinkMan"];
                        newRow["Mobile"]         = row["Mobile"];
                        newRow["CabinetName"]    = row["CabinetName"];
                        newRow["Size"]           = row["Size"];
                        newRow["Color"]          = row["Color"];
                        newRow["MaterialStyle"]  = row["MaterialStyle"];
                        newRow["PackageNum"]     = row["PackageNum"];
                        newRow["TotalPackage"]   = "";// row["TotalPackage"].ToString();
                        newRow["PackageBarcode"] = row["PackageBarcode"];
                        newRow["Address"]        = row["Province"].ToString() + row["City"].ToString() + row["Address"].ToString();
                        newRow["Barcode"]        = CommonView.getQRcode(row["PackageBarcode"].ToString());
                        newRow["PackageDesc"]    = string.Format("第 {0} 包", int.Parse(row["PackageNum"].ToString()).ToString("00"));
                        newRow["Logo"]           = CommonView.getLogoFile(LogoFile);
                        newRow["PrintDate"]      = DateTime.Now.ToString("yyyy年MM月dd日");

                        //处理列数据
                        for (int rowindex = 1; rowindex <= 3; rowindex++)
                        {
                            var    item     = lists[i * 3 + rowindex - 1];
                            string remarks  = "";
                            string itemName = item.ItemName;
                            if ("A,B,C,D,E,F".Contains(itemName.Substring(0, 1)))
                            {
                                itemName = itemName.Substring(1);
                            }

                            int index = item.ItemName.LastIndexOf("mm");
                            if (index >= 0)
                            {
                                itemName = itemName.Substring(index + 2, itemName.Length - (index + 2));
                            }
                            if (item.ItemName.Length > 5)
                            {
                                remarks = string.Format("{0}:{1}*{2}*{3}={4}", itemName.Substring(0, 5), item.MadeLength.ToString("#"), item.MadeWidth.ToString("#"), item.MadeHeight.ToString("#"), item.Qty);
                            }
                            else
                            {
                                remarks = string.Format("{0}:{1}*{2}*{3}={4}", itemName, item.MadeLength.ToString("#"), item.MadeWidth.ToString("#"), item.MadeHeight.ToString("#"), item.Qty);
                            }
                            newRow["ItemName_" + rowindex] = remarks;
                            if (i * 3 + rowindex - 1 == lists.Count - 1)
                            {
                                break;                                          //最后一条数据
                            }
                        }
                        newRow["ItemsQty"] = totalQty;// row["ItemsQty"];
                        tb.Rows.Add(newRow);
                    }
                    //生成右侧空数据,默认生成13行数据
                    for (int i = rows; i < 13; i++)
                    {
                        DataRow newRow = tb.NewRow();
                        newRow["OrderNo"]        = row["OrderNo"];
                        newRow["OutOrderNo"]     = row["OutOrderNo"];
                        newRow["PurchaseNo"]     = row["PurchaseNo"];
                        newRow["CustomerName"]   = row["CustomerName"];
                        newRow["Address"]        = row["Address"];
                        newRow["LinkMan"]        = row["LinkMan"];
                        newRow["Mobile"]         = row["Mobile"];
                        newRow["CabinetName"]    = row["CabinetName"];
                        newRow["Size"]           = row["Size"];
                        newRow["Color"]          = row["Color"];
                        newRow["MaterialStyle"]  = row["MaterialStyle"];
                        newRow["PackageNum"]     = row["PackageNum"];
                        newRow["TotalPackage"]   = "";
                        newRow["PackageBarcode"] = row["PackageBarcode"];
                        newRow["Address"]        = row["Province"].ToString() + row["City"].ToString() + row["Address"].ToString();
                        newRow["Barcode"]        = CommonView.getQRcode(row["PackageBarcode"].ToString());
                        newRow["PackageDesc"]    = string.Format("第 {0} 包", int.Parse(row["PackageNum"].ToString()).ToString("00"));
                        newRow["Logo"]           = CommonView.getLogoFile(LogoFile);
                        newRow["PrintDate"]      = DateTime.Now.ToString("yyyy年MM月dd日");
                        newRow["ItemName_1"]     = "";
                        newRow["ItemName_2"]     = "";
                        newRow["ItemName_3"]     = "";
                        newRow["ItemsQty"]       = totalQty;
                        tb.Rows.Add(newRow);
                    }
                }
                ds.Tables.Add(tb);
                #endregion
            }
            //string str = JSONHelper.Dataset2Json2(ds);
            return(ds);
        }
 public GenerateHexView()
 {
     InitializeComponent();
     CommonView.HideAllButton();
 }
Esempio n. 19
0
 public EncodeDecodeView()
 {
     InitializeComponent();
     CommonView.HideAllButton();
 }
 public GenerateProcessIdView()
 {
     InitializeComponent();
     CommonView.HideAllButton();
 }
        public ActionResult Save(LoBViewModel data)
        {
            string     username = User.Identity.GetUserName();
            CommonView model    = new CommonView();
            string     message  = string.Empty;
            long       lobID    = 0;

            try
            {
                #region Update/Create data
                if (data.ID > 0)
                {
                    //update
                    data.DateModified = DateTime.Now;
                    data.ModifiedBy   = username;
                    _lobService.Update(data);
                    lobID = data.ID;
                    _siteCampaignLobService.Deactivate(lobID);
                }
                else
                {
                    //create LOB
                    data.DateCreated = DateTime.Now;
                    data.CreatedBy   = username;
                    var lob = _lobService.Create(data);

                    lobID = data.ID;
                    _siteCampaignLobService.Deactivate(lobID);
                }

                #endregion

                foreach (var siteCampaignID in data.SiteCampaignIds.TrimEnd(',').Split(','))
                {
                    long id = Convert.ToInt64(siteCampaignID);
                    //check if lobname exists
                    var siteCampaign = _siteCampaignService.Get(id, true);

                    long siteid     = 0;
                    long campaignid = 0;
                    //long lobid = lobID;

                    #region Create/Update
                    if (siteCampaign != null)
                    {
                        var siteCampaignLob = _siteCampaignLobService.GetAll().Where(x => x.SiteID == siteCampaign.SiteID &&
                                                                                     x.CampaignID == siteCampaign.CampaignID && x.LobID == lobID)
                                              .FirstOrDefault();

                        if (siteCampaignLob != null)
                        {
                            //update
                            siteCampaignLob.Active = true;

                            _siteCampaignLobService.Update(siteCampaignLob);
                        }
                        else
                        {
                            //create SiteCampaignLOB
                            _siteCampaignLobService.Create(new SiteCampaignLoBViewModel()
                            {
                                SiteID     = siteCampaign.SiteID,
                                CampaignID = siteCampaign.CampaignID,
                                LobID      = lobID,
                                Active     = true
                            });
                        }
                        siteid     = siteCampaign.SiteID;
                        campaignid = siteCampaign.CampaignID;

                        message = "Lob Saved.";
                    }
                    #endregion

                    //Check if site campaign lob  have weeklyahdatapoin,weeklystaffdatapoint,weeklyhiringdatapoin
                    //      create those data.
                    if (siteid > 0 && campaignid > 0 && lobID > 0)
                    {
                        _lobService.CreateWeeklyDatapoints(siteid, campaignid, lobID);
                    }
                }

                model.Message = message;
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(ArgumentException))
                {
                    model.Message = ((ArgumentException)ex).Message;
                }
                else
                {
                    model.Message = "Unable to save data. Please contact your system administrator.";
                }
            }


            return(Json(model, JsonRequestBehavior.AllowGet));
        }