コード例 #1
0
        private void RefreshItems(object sender, EventArgs e)
        {
            var biz = new ProductTypeBiz();

            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
コード例 #2
0
ファイル: FindProduct.cs プロジェクト: chauit/ElectronicStore
        private void LoadProductType()
        {
            var biz = new ProductTypeBiz();
            var items = biz.LoadItems();
            items.Insert(0, new ProductType());

            drlProductType.Items.Clear();
            drlProductType.DataSource = items;
            drlProductType.DisplayMember = "Name";
            drlProductType.ValueMember = "Id";
        }
コード例 #3
0
        private void LoadProductType()
        {
            var biz   = new ProductTypeBiz();
            var items = biz.LoadItems();

            items.Insert(0, new ProductType());

            drlProductType.Items.Clear();
            drlProductType.DataSource    = items;
            drlProductType.DisplayMember = "Name";
            drlProductType.ValueMember   = "Id";
        }
コード例 #4
0
        public ProductTypeView(User user)
        {
            InitializeComponent();

            dataGridView.AutoGenerateColumns = false;

            var biz = new ProductTypeBiz();
            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();

            currentUser = user;

            buttonSelectItems.Text = "Chọn";
        }
コード例 #5
0
        public ProductTypeView(User user)
        {
            InitializeComponent();

            dataGridView.AutoGenerateColumns = false;

            var biz = new ProductTypeBiz();

            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();

            currentUser = user;

            buttonSelectItems.Text = "Chọn";
        }
コード例 #6
0
        private void DeleteItem(object sender, EventArgs e)
        {
            var items = new List<ProductType>();

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[0].Value == "1")
                {
                    items.Add(row.DataBoundItem as ProductType);
                }
            }

            var biz = new ProductTypeBiz();
            biz.RemoveItem(items);

            RefreshItems(sender, e);
        }
コード例 #7
0
ファイル: ProductForm.cs プロジェクト: chauit/ElectronicStore
        private void InitForm(User user)
        {
            buttonSave.DialogResult = System.Windows.Forms.DialogResult.OK;
            button2.DialogResult    = System.Windows.Forms.DialogResult.Cancel;

            currentUser = user.Id;

            var biz   = new ProductTypeBiz();
            var types = biz.LoadItems();

            types.Insert(0, new ProductType());

            drlType.Items.Clear();
            drlType.DataSource    = types;
            drlType.DisplayMember = "Name";
            drlType.ValueMember   = "Id";
        }
コード例 #8
0
        private void DeleteItem(object sender, EventArgs e)
        {
            var items = new List <ProductType>();

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[0].Value == "1")
                {
                    items.Add(row.DataBoundItem as ProductType);
                }
            }

            var biz = new ProductTypeBiz();

            biz.RemoveItem(items);

            RefreshItems(sender, e);
        }
コード例 #9
0
        public ProductTypeForm(int id, User user)
        {
            InitializeComponent();

            textName.Focus();
            itemId = id;

            var biz  = new ProductTypeBiz();
            var item = biz.LoadItem(id);

            textName.Text = item.Name;
            created       = item.Created;
            createdBy     = item.CreatedByUserId;
            modified      = item.Modified;
            modifiedBy    = item.ModifiedByUserId;

            InitForm(user);

            this.Text = "Sửa loại sản phẩm";
        }
コード例 #10
0
        public ProductTypeForm(int id, User user)
        {
            InitializeComponent();

            textName.Focus();
            itemId = id;

            var biz = new ProductTypeBiz();
            var item = biz.LoadItem(id);

            textName.Text = item.Name;
            created = item.Created;
            createdBy = item.CreatedByUserId;
            modified = item.Modified;
            modifiedBy = item.ModifiedByUserId;

            InitForm(user);

            this.Text = "Sửa loại sản phẩm";
        }
コード例 #11
0
        private void SaveItem(object sender, EventArgs e)
        {
            if (CustomValidation())
            {
                var item = new ProductType();
                item.Name = textName.Text;

                if (itemId > 0)
                {
                    item.Id              = itemId;
                    item.Created         = created;
                    item.CreatedByUserId = createdBy;

                    item.Modified         = DateTime.Now;
                    item.ModifiedByUserId = currentUser;

                    var biz = new ProductTypeBiz();
                    biz.UpdateItem(item);
                }
                else
                {
                    item.Created         = DateTime.Now;
                    item.CreatedByUserId = currentUser;

                    item.Modified         = DateTime.Now;
                    item.ModifiedByUserId = currentUser;

                    var biz = new ProductTypeBiz();
                    biz.SaveItem(item);
                }

                this.Close();
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
コード例 #12
0
        private void InitForm(User user)
        {
            buttonSave.DialogResult = System.Windows.Forms.DialogResult.OK;
            button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;

            currentUser = user.Id;

            var biz = new ProductTypeBiz();
            var types = biz.LoadItems();
            types.Insert(0, new ProductType());

            drlType.Items.Clear();
            drlType.DataSource = types;
            drlType.DisplayMember = "Name";
            drlType.ValueMember = "Id";
        }
コード例 #13
0
 private void RefreshItems(object sender, EventArgs e)
 {
     var biz = new ProductTypeBiz();
     dataGridView.DataSource = biz.LoadItems();
     dataGridView.Refresh();
 }
コード例 #14
0
        private void SaveItem(object sender, EventArgs e)
        {
            if (CustomValidation())
            {
                var item = new ProductType();
                item.Name = textName.Text;

                if (itemId > 0)
                {
                    item.Id = itemId;
                    item.Created = created;
                    item.CreatedByUserId = createdBy;

                    item.Modified = DateTime.Now;
                    item.ModifiedByUserId = currentUser;

                    var biz = new ProductTypeBiz();
                    biz.UpdateItem(item);
                }
                else
                {
                    item.Created = DateTime.Now;
                    item.CreatedByUserId = currentUser;

                    item.Modified = DateTime.Now;
                    item.ModifiedByUserId = currentUser;

                    var biz = new ProductTypeBiz();
                    biz.SaveItem(item);
                }

                this.Close();
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }