Ejemplo n.º 1
0
        public void AddNode(Model.Supplier supplierAdd)
        {
            TreeNode treenode = currentNode;

            if (treenode == null)
            {
                return;
            }
            TreeTagGroupSupplier treetag = treenode.Tag as TreeTagGroupSupplier;
            TreeTagGroupSupplier tree    = new TreeTagGroupSupplier
            {
                ParrentId = treetag.ParrentId,
                GroupId   = treetag.GroupId
            };
            TreeNode treenodeparrent = new TreeNode();

            if (treetag.ParrentId == 0)
            {
                tree.ParrentId  = treetag.GroupId;
                treenodeparrent = treenode;
            }
            else
            {
                tree.ParrentId  = treetag.ParrentId;
                treenodeparrent = treenode.Parent;
            }
            try
            {
                GroupSupplier group = new GroupSupplier
                {
                    GroupName   = supplierAdd.SupplierName,
                    ParentGroup = tree.ParrentId
                };
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    group.GroupId = supplierAdd.GroupId = uow.SupplierRepository.AddGroup(group);
                    uow.SupplierRepository.Update(supplierAdd);
                    uow.Commit();
                }
                TreeNode             treenodeinsert = new TreeNode();
                TreeTagGroupSupplier treetaginsert  = new TreeTagGroupSupplier
                {
                    ParrentId = group.ParentGroup,
                    GroupId   = group.GroupId
                };
                treenodeinsert.Tag  = treetaginsert;
                treenodeinsert.Text = supplierAdd.SupplierName;
                treenodeparrent.Nodes.Add(treenodeinsert);
                treeviewsupplier.SelectedNode = treenodeinsert;
                currentNode = treeviewsupplier.SelectedNode;
                FormatTreeView(supplierAdd);
                treeviewsupplier.Refresh();
            }
            catch (Exception)
            {
                return;
            }
        }
Ejemplo n.º 2
0
        public GroupSupplier AddandGetSupplierID(Supplier entry, string parrentgroup)
        {
            GroupSupplier groupSuppler = new GroupSupplier();
            Users         user         = entry.User;
            SubSupplier   subSupplier  = entry.SubSupplier;

            if (user == null || subSupplier == null)
            {
                groupSuppler = null;
            }
            int idUser = -1;

            user.SetCreate();
            groupSuppler = new GroupSupplier
            {
                GroupName   = entry.SupplierName,
                ParentGroup = int.Parse(parrentgroup)
            };
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    idUser = uow.UsersRepository.AddAndGetID(user);
                    if (idUser < 0)
                    {
                        return(null);
                    }

                    entry.SetCreate();
                    entry.GroupId = uow.SupplierRepository.AddGroup(groupSuppler);
                    if (entry.GroupId < 0)
                    {
                        return(null);
                    }
                    groupSuppler.GroupId = entry.GroupId;
                    entry.SupplierId     = uow.SupplierRepository.AddandGetSupplierID(entry);
                    if (entry.SupplierId < 0)
                    {
                        return(null);
                    }
                    subSupplier.UserId = idUser;
                    subSupplier.SetCreate();
                    subSupplier.SupplierId = entry.SupplierId;
                    subSupplier.IsMain     = true;
                    subSupplier.IsActive   = true;
                    uow.SubSupplierRepository.Add(subSupplier);
                    uow.Commit();
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(groupSuppler);
        }
Ejemplo n.º 3
0
        private void deletesuppliertreenode(object sender, EventArgs e)
        {
            TreeNode treenode = treeviewsupplier.SelectedNode;

            if (treenode == null)
            {
                return;
            }
            GroupSupplier groupsupplier = null;

            using (IUnitOfWork uow = new UnitOfWork())
            {
                groupsupplier = uow.SupplierRepository.FindGroupName(treenode.Text);
            }
            if (groupsupplier == null)
            {
                return;
            }
            Model.Supplier supplier = null;
            using (IUnitOfWork uow = new UnitOfWork())
            {
                supplier = uow.SupplierRepository.FindByGroupSupplierID(groupsupplier.GroupId);
            }


            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.SupplierRepository.DeleteGroupSupplier(groupsupplier.GroupId);
                    if (supplier != null)
                    {
                        uow.SupplierRepository.Remove(supplier.SupplierId);
                    }
                    uow.Commit();
                }
                lblNotify1.SetText(UI.DeleteSuccess, LabelNotify.EnumStatus.Success, 3000);
                treeviewsupplier.Nodes.Remove(treenode);
            }
            catch (Exception exe)
            {
                lblNotify1.SetText(UI.DeleteFail, LabelNotify.EnumStatus.Failed, 3000);
            }
        }
Ejemplo n.º 4
0
        private void FormatTreeView(Model.Supplier supplierformat)
        {
            if (supplierformat == null)
            {
                return;
            }
            int           status             = supplierformat.ApproveStatusId;
            GroupSupplier groupsupplierinser = null;

            using (IUnitOfWork uow = new UnitOfWork())
            {
                groupsupplierinser = uow.SupplierRepository.FindGroupID(supplierformat.GroupId);
                if (groupsupplierinser != null)
                {
                    groupsupplierinser.ApproveStatusId = supplierformat.ApproveStatusId;

                    uow.SupplierRepository.Updategroupsupplier(groupsupplierinser);
                    uow.Commit();
                }
            }

            if (groupsupplierinser == null)
            {
                return;
            }
            if (groupsupplierinser.ApproveStatusId == ConstraintApproveStatus.ProcessStatus)
            {
                currentNode.ImageIndex = 2;
            }
            else if (groupsupplierinser.ApproveStatusId == ConstraintApproveStatus.ApproveStatus)
            {
                currentNode.BackColor  = ColorTranslator.FromHtml("#38b04a");
                currentNode.ImageIndex = 0;
            }
            else if (groupsupplierinser.ApproveStatusId == ConstraintApproveStatus.CancelStatus)
            {
                currentNode.BackColor  = Color.FromArgb(((int)(((byte)(69)))), ((int)(((byte)(95)))), ((int)(((byte)(115)))));
                currentNode.ImageIndex = 0;
            }
            else
            {
                currentNode.ImageIndex = 2;
            }
        }
Ejemplo n.º 5
0
        //Thêm nhóm khách hàng MYSQL
        public bool InsertGroupSupplierMySQL(string pNameGroup)
        {
            if (IsGroupSupplierMySQL(pNameGroup))
            {
                DbSpaDataContext db = new DbSpaDataContext();

                GroupSupplier t = new GroupSupplier();
                t.ID        = MaxIDTypeMySQL() + 1;
                t.NAMEGROUP = pNameGroup;
                t.STATUS    = 1;

                db.GroupSuppliers.InsertOnSubmit(t);
                db.SubmitChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        public void UpdateNode(Model.Supplier supplierUpdate)
        {
            TreeNode treenode = currentNode;

            treenode.Text = supplierUpdate.SupplierName;
            TreeTagGroupSupplier treetag       = treenode.Tag as TreeTagGroupSupplier;
            GroupSupplier        groupSupplier = new GroupSupplier
            {
                GroupId     = treetag.GroupId,
                ParentGroup = treetag.ParrentId,
                GroupName   = treenode.Text
            };

            using (UnitOfWork uow = new UnitOfWork())
            {
                uow.GroupSupplierRepository.Edit(groupSupplier);
                uow.Commit();
            }
            treenode.TreeView.Refresh();
        }
Ejemplo n.º 7
0
        private void deletesupplier(object sender, EventArgs e)
        {
            TreeNode treenode = treeviewsupplier.SelectedNode;

            if (treenode == null)
            {
                return;
            }
            GroupSupplier groupsupplier = null;

            using (IUnitOfWork uow = new UnitOfWork())
            {
                groupsupplier = uow.SupplierRepository.FindGroupName(treenode.Text);
            }
            if (groupsupplier == null)
            {
                return;
            }
            frmDeleteGroupsupplier _frmDeleteGroupsupplier = new frmDeleteGroupsupplier(groupsupplier, treenode);

            _frmDeleteGroupsupplier.StartPosition = FormStartPosition.CenterParent;
            _frmDeleteGroupsupplier.ShowDialog();
        }
Ejemplo n.º 8
0
        private void updategroupsupplier(object sender, EventArgs e)
        {
            TreeNode             treenode = treeviewsupplier.SelectedNode;
            TreeTagGroupSupplier treetag  = treenode.Tag as TreeTagGroupSupplier;

            if (treenode == null || treetag.ParrentId == 0)
            {
                return;
            }
            GroupSupplier groupsupplier = null;

            using (IUnitOfWork uow = new UnitOfWork())
            {
                groupsupplier = uow.SupplierRepository.FindGroupName(treenode.Text);
            }
            if (groupsupplier == null)
            {
                return;
            }
            frmEditGroupSupplier _frmeditgrouppart = new frmEditGroupSupplier(groupsupplier, treenode);

            _frmeditgrouppart.StartPosition = FormStartPosition.CenterParent;
            _frmeditgrouppart.ShowDialog();
        }
Ejemplo n.º 9
0
 public int AddgetID(GroupSupplier groupsupplier)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtGroupName.Text))
            {
                lblNotify.SetText("không được bỏ trống", ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
            if (requestFrmGroupSupplier.groupsupplier != null)
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    requestFrmGroupSupplier.groupsupplier.GroupName = txtGroupName.Text;
                    uow.SupplierRepository.Updategroupsupplier(requestFrmGroupSupplier.groupsupplier);
                    uow.Commit();
                }
                return;
            }
            Model.GroupSupplier groupSupplier = new Model.GroupSupplier()
            {
                GroupName   = txtGroupName.Text,
                ParentGroup = 0
            };
            GroupSupplier groupSupplier1 = null;

            using (IUnitOfWork uow = new UnitOfWork())
            {
                groupSupplier1 = uow.SupplierRepository.FindGroupName(txtGroupName.Text.ToLower());
            }

            if (groupSupplier1 != null)
            {
                lblNotify.SetText("đã tồn tại group name", ToolBoxCS.LabelNotify.EnumStatus.Failed);
                return;
            }
            using (IUnitOfWork uow = new UnitOfWork())
            {
                int groupID = -1;
                try
                {
                    groupID = uow.SupplierRepository.AddGroup(groupSupplier);
                    uow.Commit();
                    groupSupplier.GroupId = groupID;
                }
                catch (Exception)
                {
                }
            }
            if (groupSupplier.GroupId < 0)
            {
                lblNotify.SetText("Tạo mới thất bại", ToolBoxCS.LabelNotify.EnumStatus.Failed);
            }
            else
            {
                TreeNode             treenode = new TreeNode();
                TreeTagGroupSupplier treetag  = new TreeTagGroupSupplier
                {
                    GroupId   = groupSupplier.GroupId,
                    ParrentId = 0
                };
                treenode.Tag        = treetag;
                treenode.Text       = groupSupplier.GroupName;
                treenode.ImageIndex = 1;
                requestFrmGroupSupplier.treeview.Nodes.Add(treenode);
                requestFrmGroupSupplier.treeview.Refresh();
                this.Close();
            }
        }
Ejemplo n.º 11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtNew.Text.Trim() == string.Empty)
            {
                lbleMessage.SetText("không được để trống, nhập lại", LabelNotify.EnumStatus.Other);
                return;
            }
            if (parameterTrans.IsInsert)
            {
                var groupInsert = new GroupSupplier
                {
                    ParentGroup = int.Parse(parameterTrans.ParrentId),
                    GroupName   = txtNew.Text
                };

                var treeInsert = parameterTrans.Treenode;

                if (treeInsert.Parent == null)
                {
                    groupInsert.ParentGroup = 0;
                }


                var id = 0;
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    id = uow.SupplierRepository.AddGroup(groupInsert);
                    uow.Commit();
                }
                if (id > 0)
                {
                    groupInsert.Id = id.ToString();
                }

                var treenode = new TreeNode
                {
                    Text = txtNew.Text
                };
                TreeTagGroupSupplier treetag = new TreeTagGroupSupplier
                {
                    ParrentId = groupInsert.ParentGroup,
                    GroupId   = groupInsert.GroupId
                };

                treenode.Tag = treetag;
                if (!parameterTrans.TyepParrent)
                {
                    if (treeInsert.Nodes.Count > 0)
                    {
                        if (treeInsert.Parent != null)
                        {
                            treeInsert.Parent.Nodes.Add(treenode);
                        }
                    }
                    else
                    {
                        treeInsert.Nodes.Add(treenode);
                    }
                }
                else
                {
                    try
                    {
                        if (treeInsert.Parent != null)
                        {
                            treeInsert.Parent.Nodes.Add(treenode);
                        }
                        else
                        {
                            treeInsert.TreeView.Nodes.Add(treenode);
                        }
                    }
                    catch (Exception)
                    {
                        treeInsert.TreeView.Nodes.Add(treenode);
                    }
                }
                treeInsert.TreeView.Tag = treeInsert;
                treeInsert.TreeView.Refresh();
            }
        }
Ejemplo n.º 12
0
 public frmEditGroupSupplier(GroupSupplier groupsupplier, TreeNode treenode)
 {
     InitializeComponent();
     m_treenode      = treenode;
     m_groupsupplier = groupsupplier;
 }
Ejemplo n.º 13
0
        public int AddGroup(GroupSupplier groupsupplier)
        {
            string insert = (" insert into GroupSupplier(GroupName, ParentGroup) output inserted.GroupID values(@GroupName, @ParentGroup)");

            return(Connection.ExecuteScalar <int>(insert, groupsupplier, Transaction));
        }
Ejemplo n.º 14
0
        public void deletegroup(GroupSupplier m_groupsupplier)
        {
            string delete = ("delete from GroupSupplier  where GroupID = " + m_groupsupplier.GroupId);

            Connection.Execute("delete from GroupSupplier  where GroupID  =@GroupID", param: new { GroupID = m_groupsupplier.GroupId }, transaction: Transaction);
        }
Ejemplo n.º 15
0
 public void Updategroupsupplier(GroupSupplier groupsupplier)
 {
     Connection.Execute("update GroupSupplier set GroupName  =@GroupName, ApproveStatusId =@ApproveStatusId where GroupID =   @GroupID ", param: new { GroupID = groupsupplier.GroupId, GroupName = groupsupplier.GroupName, ApproveStatusId = groupsupplier.ApproveStatusId }, transaction: Transaction);
 }