Beispiel #1
0
        void ucGroupList_btnSave_Click(object sender, EventArgs e)
        {
            Button btnSaveGroup = (Button)sender;
            CategoryModel tag = (CategoryModel)(btnSaveGroup.Tag);

            var ucGroupItem = (UCGroupList)pnDetail.Controls[0];

            if (tag == null)
            {
                tag = new CategoryModel();
            }

            tag.CategoryName = ucGroupItem.txtGroupNameDesc.Text;
            tag.CategoryNameSort = ucGroupItem.txtGroupNameSort.Text ?? "";
            tag.Color = ucGroupItem.cbGroupColor.Text ?? "";
            tag.ProductColor = ucGroupItem.cbProductColor.Text ?? "";
            if (tag.CategoryName != "")
            {
                var result = CatalogeService.SaveDataCategory(tag);
                var message = "";
                if (result == 1)
                {

                    addGroupList("Group List", 2, this.CurrentPage);
                    message = "Save data group successful.";
                }
                else
                {
                    if (result == -1)
                    {
                        message = "Menu name already exist. Please change group name.";
                    }
                    else
                    {
                        message = "Save data group fail";
                    }

                }
                frmMessager frm = new frmMessager("Messenger", message);
                frmOpacity.ShowDialog(this, frm);
            }
            else
            {
                frmMessager frm = new frmMessager("Messenger", "Group name isn't empty.");
                frmOpacity.ShowDialog(this, frm);
            }
        }
Beispiel #2
0
 private void btnLeft_Click(object sender, EventArgs e)
 {
     foreach (Control ctr in flpAllitems.Controls)
     {
         if (ctr.BackColor == Color.FromArgb(0, 102, 204))
         {
             UCMenuAdd ucMenuGet = (UCMenuAdd)ctr;
             CategoryModel itemlef = (CategoryModel) (ucMenuGet.Tag);
             CategoryModel item = new CategoryModel();
             item.CategoryID = itemlef.CategoryID;
             item.CategoryName = itemlef.CategoryName;
             listmap.Add(item);
             var index = -1;
             for(int i=0;i<listall.Count;i++)
             {
                 if (listall[i].CategoryID == item.CategoryID)
                 {
                     index = i;
                 }
             }
             if (index> - 1)
             {
                 listall.RemoveAt(index);
             }
         }
     }
     LoadThisGroupItems();
     LoadAllItem();
 }
Beispiel #3
0
        private void addGroupListDetail(CategoryModel cate)
        {
            //pnDetail.Controls.Clear();

            if (cate.CategoryID > 0)
            {
                UCGroupList ucGroupList = new UCGroupList();
                if (pnDetail.Controls.Count > 0)
                {
                    ucGroupList = (UCGroupList)pnDetail.Controls[0];
                }
                else
                {
                    ucGroupList.Dock = DockStyle.Fill;
                    pnDetail.Controls.Add(ucGroupList);
                }

                ucGroupList.lblTilte.Text = cate.CategoryName;
                ucGroupList.txtGroupNameDesc.Text = cate.CategoryName;
                ucGroupList.txtGroupNameSort.Text = cate.CategoryNameSort;

                ucGroupList.btnSave.Tag = cate;
                ucGroupList.btnSave.Click += ucGroupList_btnSave_Click;

                ucGroupList.btnRemove.Tag = cate;
                ucGroupList.btnRemove.Click += ucGroupList_btnRemove_Click;

                ucGroupList.flpGroup.Controls.Clear();
                ucGroupList.addUcMenuGroup(cate.CategoryID, 1);

                ucGroupList.cbGroupColor.SelectedItem = cate.Color;
                ucGroupList.cbProductColor.SelectedItem = cate.ProductColor;
            }
            else
            {
                pnDetail.Controls.Clear();
            }
        }
Beispiel #4
0
        public int SaveDataCategory(CategoryModel cate)
        {
            try
            {

                if (cate.CategoryID == 0)
                {
                    var checkdata = _context.CATEGORies.Where(x => x.CategoryName == cate.CategoryName).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return -1;
                    }

                    var data = new CATEGORY();
                    data.CategoryName = cate.CategoryName;
                    data.CategoryNameSort = cate.CategoryNameSort ?? "";
                    data.Color = cate.Color ?? "";
                    data.ProductColor = cate.ProductColor ?? "";
                    data.Status = 1;
                    data.CreateBy = cate.CreateBy ?? 1;
                    data.CreateDate = DateTime.Now;
                    data.UpdateBy = cate.UpdateBy ?? 0;
                    data.UpdateDate = DateTime.Now;
                    data.Note = cate.Note ?? "";

                    _context.Entry(data).State = EntityState.Added;
                    _context.SaveChanges();

                    return 1;

                }
                else
                {
                    var checkdata = _context.CATEGORies.Where(x => x.CategoryName == cate.CategoryName && x.CategoryID != cate.CategoryID).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return -1;
                    }
                    var data = _context.CATEGORies.Find(cate.CategoryID);
                    if (data != null)
                    {
                        data.CategoryName = cate.CategoryName;
                        data.CategoryNameSort = cate.CategoryNameSort ?? "";
                        data.Color = cate.Color ?? "";
                        data.ProductColor = cate.ProductColor ?? "";
                        data.Status = 1;
                        data.UpdateBy = cate.UpdateBy ?? 1;
                        data.UpdateDate = DateTime.Now;
                        data.Note = cate.Note ?? "";

                        _context.Entry(data).State = EntityState.Modified;
                        _context.SaveChanges();

                        return 1;
                    }
                    return 0;

                }
            }
            catch (Exception)
            {
                return 0;
            }
        }