/*
        Metodo para insertar un nuevo producto
        */
        protected void addProcess_Click(object sender, EventArgs e)
        {
            string value = ValueProduct.Text;
            if (value != "")
            {
                ProcessService processService = new ProcessService();

                String user = Context.User.Identity.Name;
                AuditDataFromWeb audit = new AuditDataFromWeb();
                audit.Reason = "N/A";
                audit.StationIP = General.getIp(this.Page);
                audit.UserName = user;

                CUDView crud = processService.insertProduct(value, audit);

                if (crud.insert == false)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the Value')", true);
                }
                else
                {
                    ValueProduct.Text = "";
                    fillProductGroupTable();
                    updateProductModal.Update();
                }

            }
        }
        public IQueryable <ComboBoxResult> GetCustomPerson(int Id, string term)
        {
            int DocTypeId  = Id;
            int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];

            var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(DocTypeId, DivisionId, SiteId);

            string[] PersonRoles = null;
            if (!string.IsNullOrEmpty(settings.filterPersonRoles))
            {
                PersonRoles = settings.filterPersonRoles.Split(",".ToCharArray());
            }
            else
            {
                PersonRoles = new string[] { "NA" };
            }

            string DivIdStr  = "|" + DivisionId.ToString() + "|";
            string SiteIdStr = "|" + SiteId.ToString() + "|";

            int ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Sales).ProcessId;

            var list = (from p in db.Persons
                        join bus in db.BusinessEntity on p.PersonID equals bus.PersonID into BusinessEntityTable
                        from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty()
                        join pp in db.PersonProcess on p.PersonID equals pp.PersonId into PersonProcessTable
                        from PersonProcessTab in PersonProcessTable.DefaultIfEmpty()
                        join pr in db.PersonRole on p.PersonID equals pr.PersonId into PersonRoleTable
                        from PersonRoleTab in PersonRoleTable.DefaultIfEmpty()
                        where PersonProcessTab.ProcessId == ProcessId &&
                        (string.IsNullOrEmpty(term) ? 1 == 1 : (p.Name.ToLower().Contains(term.ToLower()) || p.Code.ToLower().Contains(term.ToLower()))) &&
                        (string.IsNullOrEmpty(settings.filterPersonRoles) ? 1 == 1 : PersonRoles.Contains(PersonRoleTab.RoleDocTypeId.ToString())) &&
                        BusinessEntityTab.DivisionIds.IndexOf(DivIdStr) != -1 &&
                        BusinessEntityTab.SiteIds.IndexOf(SiteIdStr) != -1 &&
                        (p.IsActive == null ? 1 == 1 : p.IsActive == true)
                        group new { p } by new { p.PersonID } into Result
                        orderby Result.Max(m => m.p.Name)
                        select new ComboBoxResult
            {
                id = Result.Key.PersonID.ToString(),
                text = Result.Max(m => m.p.Name + ", " + m.p.Suffix + " [" + m.p.Code + "]"),
            }
                        );

            return(list);
        }
Пример #3
0
        public RateListViewModel GetNewRateListForWeaving(int ProductGroupId, int PersonRateGroupId)
        {
            var ProcessId     = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId.ToString();
            int ProductTypeId = new ProductTypeService(_unitOfWork).Find(ProductTypeConstants.Rug).ProductTypeId;

            var temp = (from p in db.ProductGroups
                        from t in db.PersonRateGroup.Where(m => m.Processes.IndexOf(ProcessId) != -1)
                        join t2 in db.RateList on new { x = p.ProductGroupId, y = t.PersonRateGroupId } equals new { x = t2.DocId.Value, y = t2.PersonRateGroupId.Value } into table
                        from tab in table.DefaultIfEmpty()
                        where p.ProductTypeId == ProductTypeId && p.ProductGroupId == ProductGroupId && t.PersonRateGroupId == PersonRateGroupId
                        orderby p.ProductGroupName
                        select new RateListViewModel {
                Design = p.ProductGroupName, ProductGroupId = p.ProductGroupId, PersonRateGroupName = t.PersonRateGroupName, PersonRateGroupId = t.PersonRateGroupId, Rate = tab.Rate, WEF = DateTime.Now, RateListId = tab.RateListId, Loss = tab.Loss, UnCountedQty = tab.UnCountedQty
            }).FirstOrDefault();

            return(temp);
        }
        protected void addProcess_Click(object sender, EventArgs e)
        {
            string value = ValueProduct.Text;
            if (value != "")
            {
                ProcessService processService = new ProcessService();
                CUDView crud = processService.insertProduct(value);

                if (crud.insert == false)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the Value')", true);
                }
                else
                {
                    ValueProduct.Text = "";
                    fillProductGroupTable();
                    updateProductModal.Update();
                }

            }
        }
        /*
        Metodo para actualizar un producto
        */
        private void updateProcessGroupAux()
        {
            if (HttpContext.Current.Session["ProductId"] != null)
            {
                string value = ValueProduct.Text;
                if (value != "")
                {
                    ProcessService processService = new ProcessService();
                    ProductUpdateView ProductsView = new ProductUpdateView();

                    String reason = Session["reason"].ToString();
                    String user = Context.User.Identity.Name;
                    AuditDataFromWeb audit = new AuditDataFromWeb();
                    audit.Reason = reason;
                    audit.StationIP = General.getIp(this.Page);
                    audit.UserName = user;

                    ProductsView.ProductLineId = Int32.Parse(HttpContext.Current.Session["ProductId"].ToString());
                    ProductsView.ProductLineName = value;

                    CUDView crud = processService.updateProduct(ProductsView,audit);

                    if (crud.update == false)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Value')", true);
                    }
                    else
                    {
                        ValueProduct.Text = "";
                        fillProductGroupTable();
                        updateProductModal.Update();
                    }
                    HttpContext.Current.Session["operation"] = "create";
                    showProductModal();
                }
            }
        }
        /*
        Metodo que se utiliza para actualizar un proceso existente
        */
        private void updateAuxiliar()
        {
            if (HttpContext.Current.Session["ProcessId"] != null)
            {

                String reason = Session["reason"].ToString();
                String user = Context.User.Identity.Name;
                AuditDataFromWeb audit = new AuditDataFromWeb();
                audit.Reason = reason;
                audit.StationIP = General.getIp(this.Page);
                audit.UserName = user;

                ProcessService processService = new ProcessService();
                ProcessUpdateView processUpdate = new ProcessUpdateView();

                processUpdate.ProcessId = Int32.Parse(HttpContext.Current.Session["ProcessId"].ToString());
                processUpdate.ProcessPlotEnable = plotEnableText.Items[0].Selected;

                CUDView crud = processService.updateProcess(processUpdate,audit);

                if (crud.update == false)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Process')", true);
                }
                else
                {
                    clearFields();
                    fillProcessTable();
                }

            }
        }
        /*
        Metodo que se utiliza para hacer una insercion de un nuevo proceso
        */
        private void saveAuxiliar()
        {
            if (ProductText.SelectedItem != null)
            {
                if (ProcessText.Text != "" & ProductText.SelectedItem.Value != "")
                {

                    ProcessService processService = new ProcessService();
                    ProcessInsertView insertView = new ProcessInsertView();

                    insertView.ProcessName = ProcessText.Text;
                    insertView.ProductLineId = Int32.Parse(ProductText.SelectedItem.Value);
                    insertView.ProcessParameterSet = parameterSetText.Items[0].Selected;
                    insertView.ProcessPlotEnable = plotEnableText.Items[0].Selected;

                    String user = Context.User.Identity.Name;

                    AuditDataFromWeb audit = new AuditDataFromWeb();
                    audit.Reason = "N/A";
                    audit.StationIP = General.getIp(this.Page);
                    audit.UserName = user;

                    CUDView crud = processService.insertProcess(insertView, audit);

                    if (crud.insert == false)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the Process')", true);
                    }
                    else
                    {
                        clearFields();
                        fillProcessTable();
                    }

                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true);
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true);
            }
        }
 /*
 Metodo que llena la tabla de product group
 */
 private void fillProductGroupTable()
 {
     ProcessService processService = new ProcessService();
     List<ProductsView> products = processService.getProducts();
     GridView2.DataSource = products;
     GridView2.DataBind();
 }
 /*
 Metodo que llena el producto
 */
 private void fillProductGroup()
 {
     ProcessService processService = new ProcessService();
     List<ProductsView> products = processService.getProducts();
     ProductText.DataSource = products;
     ProductText.DataBind();
 }
 /*
 Metodo que llena la tabla de procesos
 */
 private void fillProcessTable()
 {
     ProcessService processService = new ProcessService();
     List<ProcessView> processData = processService.getProcess();
     GridView3.DataSource = processData;
     GridView3.PageIndex = 0;
     GridView3.DataBind();
 }
 /*
 Metodo que llena la tabla de procesos con los datos filtrados por una busqueda
 */
 protected void searchButton_Click(object sender, ImageClickEventArgs e)
 {
     ProcessService processService = new ProcessService();
     List<ProcessView> processData = processService.searchProcess(searchText.Text);
     GridView3.DataSource = processData;
     GridView3.DataBind();
 }
        private void updateAuxiliar()
        {
            if (HttpContext.Current.Session["ProcessId"] != null)
            {
                string confirmValue = Request.Form["confirm_value"];
                if (confirmValue == "Yes")
                {
                    ProcessService processService = new ProcessService();
                    ProcessUpdateView processUpdate = new ProcessUpdateView();

                    processUpdate.ProcessId = Int32.Parse(HttpContext.Current.Session["ProcessId"].ToString());
                    processUpdate.ProcessPlotEnable = plotEnableText.Items[0].Selected;

                    CUDView crud = processService.updateProcess(processUpdate);

                    if (crud.update == false)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Process')", true);
                    }
                    else
                    {
                        clearFields();
                        fillProcessTable();
                    }

                }
            }
        }
        private void saveAuxiliar()
        {
            if (ProductText.SelectedItem != null)
            {
                if (ProcessText.Text != "" & ProductText.SelectedItem.Value != "")
                {
                    string confirmValue = Request.Form["confirm_value"];
                    if (confirmValue == "Yes")
                    {
                        ProcessService processService = new ProcessService();
                        ProcessInsertView insertView = new ProcessInsertView();

                        insertView.ProcessName = ProcessText.Text;
                        insertView.ProductLineId = Int32.Parse(ProductText.SelectedItem.Value);
                        insertView.ProcessParameterSet = parameterSetText.Items[0].Selected;
                        insertView.ProcessPlotEnable = plotEnableText.Items[0].Selected;

                        CUDView crud = processService.insertProcess(insertView);

                        if (crud.insert == false)
                        {
                            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the Process')", true);
                        }
                        else
                        {
                            clearFields();
                            fillProcessTable();
                        }
                    }
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true);
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true);
            }
        }
        protected void updateProcessGroup_Click(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["ProductId"] != null)
            {

                string value = ValueProduct.Text;
                if (value != "")
                {
                    ProcessService processService = new ProcessService();
                    ProductUpdateView ProductsView = new ProductUpdateView();

                    ProductsView.ProductLineId = Int32.Parse(HttpContext.Current.Session["ProductId"].ToString());
                    ProductsView.ProductLineName = value;

                    CUDView crud = processService.updateProduct(ProductsView);

                    if (crud.update == false)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Value')", true);
                    }
                    else
                    {
                        ValueProduct.Text = "";
                        fillProductGroupTable();
                        updateProductModal.Update();
                    }
                }
            }
        }