public ActionResult SaveProductName(ProductName_Model objModel, int page = 1, int pageSize = 10)
        {
            if (!ModelState.IsValid)
            {
                var message = string.Join("|", ModelState.Values.SelectMany(e => e.Errors).Select(em => em.ErrorMessage));
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, message));
            }

            //Save
            ProductNameManager context = new ProductNameManager(new DataContext());
            var msg = context.SaveProductName(objModel.Table);

            if (msg.Contains("exists"))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "exists"));
            }
            else
            {
                if (objModel.StaticPageSize != 0)
                {
                    pageSize = objModel.StaticPageSize;
                }
                objModel.StaticPageSize = pageSize;

                BindProductNameGrid(objModel, page, pageSize);
                return(PartialView("ProductNameList", objModel));
            }
        }
Exemple #2
0
        public FrmSearchProduct(FrmDanhMucSanPham frmParent)
        {
            InitializeComponent();

            productManager = new ProductManager();
            productNameManager = new ProductNameManager();
            categoryManager = new CategoryManager();
            unitManager = new UnitManager();
            countryManager = new CountryManager();
            manufacturerManager = new ManufacturerManager();
            productStatusManager = new ProductStatusManager();

            this.frmParent = frmParent;
        }
        public ActionResult AddEditProductname(int ID = 0)
        {
            ProductNameManager context  = new ProductNameManager(new DataContext());
            ProductName_Model  objModel = new ProductName_Model();

            if (ID != 0)
            {
                objModel.Table = context.GetProductNameById(ID);
            }
            else
            {
                objModel.Table = new Productname();
            }
            return(PartialView("ProductNameCRUD", objModel));
        }
        public void BindProductNameGrid(ProductName_Model objModel, int page, int pageSize)
        {
            StringBuilder query   = new StringBuilder();
            var           colName = common.GetColumns(CommonFunction.module.ProductName.ToString());

            query = common.GetSqlTableQuery(CommonFunction.module.ProductName.ToString());
            if (objModel != null)
            {
                objModel.StaticPageSize = pageSize;
            }

            ProductNameManager context = new ProductNameManager(new DataContext());

            context.setModel(query, objModel, colName, "Productname", page, pageSize);
        }
Exemple #5
0
        public FrmDanhMucSanPham()
        {
            InitializeComponent();

            //Create Manager which will use in form
            productManager = new ProductManager();
            productNameManager = new ProductNameManager();
            productStatusManager = new ProductStatusManager();
            unitManager = new UnitManager();

            categoryManager = new CategoryManager();
            manufacturerManager = new ManufacturerManager();
            countryManager = new CountryManager();
            providerManager = new ProviderManager();

            //
            MODE = Constants.MODE.ADD;
        }
        public ActionResult DeleteProductName(string ID, ProductName_Model objModel, int page = 1, int pageSize = 10)
        {
            ProductNameManager context = new ProductNameManager(new DataContext());

            if (!string.IsNullOrEmpty(ID))
            {
                int pId = Convert.ToInt32(ID);
                List <Productname> lst = context.GetAll(c => c.PrdID == pId).ToList();
                context.DeleteProductName(lst);
            }

            if (objModel.StaticPageSize != 0)
            {
                pageSize = objModel.StaticPageSize;
            }
            objModel.StaticPageSize = pageSize;

            BindProductNameGrid(objModel, page, pageSize);
            return(PartialView("ProductNameList", objModel));
        }
        public ActionResult SetGanttChart1(string BON = "")
        {
            ProdcutGroupGanttManager    objPGGantttManager             = new ProdcutGroupGanttManager(new DataContext());
            BuyerOrderNumberListManager objBuyerOrderNumberListManager = new BuyerOrderNumberListManager(new DataContext());
            BuyerListManager            objBuyerListManager            = new BuyerListManager(new DataContext());
            ProcessListManager          objProcessListManager          = new ProcessListManager(new DataContext());
            ProductNameManager          objProductNameManager          = new ProductNameManager(new DataContext());
            List <VW_ProdcutGroupGantt> lstData = new List <VW_ProdcutGroupGantt>();

            if (string.IsNullOrEmpty(BON))
            {
                lstData = objPGGantttManager.GetAll().ToList();
            }
            else
            {
                lstData = objPGGantttManager.GetAll(c => c.Buyername == BON).ToList();
            }
            List <TaskViewModel> lstTData = new List <TaskViewModel>();
            List <string>        lstBDN   = objBuyerListManager.GetAll().ToList().Select(c => c.BuyerName).ToList();
            List <string>        lstODN   = objBuyerOrderNumberListManager.GetAll().ToList().Select(c => c.BuyerOrderNumberName).ToList();
            List <string>        lstPSN   = objProcessListManager.GetAll().ToList().Select(c => c.ProcessName).ToList();
            List <string>        lstPDN   = objProductNameManager.GetAll().ToList().Select(c => c.ProductName).ToList();
            int ord = 1;

            foreach (string bo in lstBDN)
            {
                var lstByBON = lstData.Where(c => c.Buyername == bo);
                if (lstByBON.Count() > 0)
                {
                    DateTime sDateBON = lstByBON.Min(c => c.StartDate).Value;
                    DateTime eDateBON = lstByBON.Max(c => c.SPCDate).Value;

                    DateTime?skusDate  = lstByBON.Min(c => c.SKUStartDate);
                    DateTime?skueeDate = lstByBON.Max(c => c.SKUEndDate);
                    if (skusDate == null)
                    {
                    }
                    TaskViewModel obj = new TaskViewModel();
                    obj.ID              = ord;
                    obj.Title           = bo;
                    obj.ParentID        = null;
                    obj.PercentComplete = Convert.ToDouble(lstByBON.FirstOrDefault().Done) / 100.00;
                    obj.OrderID         = ord;
                    obj.ChildId         = ord;
                    obj.Start           = DateTime.SpecifyKind(sDateBON, DateTimeKind.Utc);
                    obj.End             = DateTime.SpecifyKind(eDateBON, DateTimeKind.Utc);
                    obj.Expanded        = true;
                    obj.Summary         = true;
                    obj.Done            = lstByBON.Max(c => c.Done);
                    obj.DelayedDays     = lstByBON.Max(c => c.DelayedDays);
                    obj.SKUStart        = skusDate;
                    obj.SKUEnd          = skueeDate;
                    lstTData.Add(obj);
                    ord++;
                    foreach (string ps in lstODN)
                    {
                        var lstByPS = lstData.Where(c => c.Buyername == bo && c.BuyerOrderNumberName == ps);
                        if (lstByPS.Count() > 0)
                        {
                            DateTime sDatePS    = lstByPS.Min(c => c.StartDate).Value;
                            DateTime eDatePS    = lstByPS.Max(c => c.SPCDate).Value;
                            DateTime?skusDate1  = lstByBON.Min(c => c.SKUStartDate);
                            DateTime?skueeDate1 = lstByBON.Max(c => c.SKUEndDate);
                            if (skusDate1 == null)
                            {
                            }
                            TaskViewModel obj1 = new TaskViewModel();
                            obj1.ID              = ord;
                            obj1.Title           = ps;
                            obj1.ParentID        = obj.ID;
                            obj1.Start           = DateTime.SpecifyKind(sDatePS, DateTimeKind.Utc);
                            obj1.End             = DateTime.SpecifyKind(eDatePS, DateTimeKind.Utc);
                            obj1.PercentComplete = Convert.ToDouble(lstByPS.FirstOrDefault().Done) / 100.00;
                            obj1.OrderID         = ord;
                            obj1.ChildId         = ord;
                            obj1.Expanded        = true;
                            obj1.Summary         = true;
                            obj1.Done            = lstByPS.Max(c => c.Done);
                            obj1.DelayedDays     = lstByPS.Max(c => c.DelayedDays);
                            obj1.SKUStart        = skusDate1;
                            obj1.SKUEnd          = skueeDate1;
                            lstTData.Add(obj1);
                            ord++;
                            foreach (string vs in lstPSN)
                            {
                                var lstByVS = lstData.Where(c => c.Buyername == bo && c.BuyerOrderNumberName == ps && c.Processname == vs);
                                if (lstByVS.Count() > 0)
                                {
                                    DateTime sDateVS    = lstByVS.Min(c => c.StartDate).Value;
                                    DateTime eDateVS    = lstByVS.Max(c => c.SPCDate).Value;
                                    DateTime?skusDate2  = lstByBON.Min(c => c.SKUStartDate);
                                    DateTime?skueeDate2 = lstByBON.Max(c => c.SKUEndDate);
                                    if (skusDate1 == null)
                                    {
                                    }
                                    TaskViewModel obj2 = new TaskViewModel();
                                    obj2.ID              = ord;
                                    obj2.Title           = vs;
                                    obj2.ParentID        = obj1.ID;
                                    obj2.Start           = DateTime.SpecifyKind(sDatePS, DateTimeKind.Utc);
                                    obj2.End             = DateTime.SpecifyKind(eDatePS, DateTimeKind.Utc);
                                    obj2.PercentComplete = Convert.ToDouble(lstByVS.FirstOrDefault().Done) / 100.00;
                                    obj2.OrderID         = ord;
                                    obj2.ChildId         = ord;
                                    obj2.Expanded        = true;
                                    obj2.Summary         = true;
                                    obj2.Done            = lstByVS.Max(c => c.Done);
                                    obj2.DelayedDays     = lstByVS.Max(c => c.DelayedDays);
                                    obj2.SKUStart        = skusDate2;
                                    obj2.SKUEnd          = skueeDate2;
                                    lstTData.Add(obj2);
                                    ord++;
                                    foreach (string pd in lstPDN)
                                    {
                                        var lstByPD = lstData.Where(c => c.Buyername == bo && c.BuyerOrderNumberName == ps && c.Processname == vs && c.Productname == pd);
                                        if (lstByPD.Count() > 0)
                                        {
                                            foreach (var objData in lstByPD)
                                            {
                                                DateTime?skusDate3  = objData.SKUStartDate;
                                                DateTime?skueeDate3 = objData.SKUEndDate;
                                                if (skusDate3 == null)
                                                {
                                                }
                                                TaskViewModel obj3 = new TaskViewModel();
                                                obj3.Title           = objData.Productname;
                                                obj3.ID              = ord;
                                                obj3.Start           = DateTime.SpecifyKind(objData.StartDate.Value, DateTimeKind.Utc);
                                                obj3.End             = DateTime.SpecifyKind(objData.SPCDate.Value, DateTimeKind.Utc);
                                                obj3.ParentID        = obj2.ID;
                                                obj3.PercentComplete = Convert.ToDouble(objData.Done) / 100.00;
                                                obj3.OrderID         = ord;
                                                obj3.ChildId         = ord;
                                                obj3.Expanded        = true;
                                                obj3.Summary         = false;
                                                obj3.NoDays          = objData.NoDays;
                                                obj3.Done            = objData.Done;
                                                obj3.DelayedDays     = objData.DelayedDays;
                                                obj3.SKUStart        = skusDate3;
                                                obj3.SKUEnd          = skueeDate3;
                                                lstTData.Add(obj3);
                                                ord++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(Json(new { data = lstTData }));
        }
Exemple #8
0
 private void cboTenSanPham_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (cboTenSanPham.SelectedValue.ToString().Length == 0) return;
         int khoa = Int32.Parse(cboTenSanPham.SelectedValue.ToString());
         ProductNameManager productNameManager = new ProductNameManager();
         ProductName productName = productNameManager.GetById(khoa, true);
         cboLoaiSanPham.SelectedValue = productName.CategoryIdLookup.ID;
         cboNhaSanXuat.SelectedValue = productName.ManIdLookup.ID;
         ManufacturerManager manufacturerManager = new ManufacturerManager();
         Manufacturer man = manufacturerManager.GetById(productName.ManIdLookup.ID, true);
         cboNguonGoc.SelectedValue = man.CountryIdLookup.ID;
     }
     catch (Exception ex) {}
 }