Ejemplo n.º 1
0
        public override IEnumerable <object> Select()
        {
            var list = new List <Suplier>();

            try
            {
                string     sql     = "select * from Suplier";
                SqlCommand command = new SqlCommand(sql, DataProvider.Instance.DB);

                using (DbDataReader reader = command.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Suplier suplier = new Suplier();
                            suplier.Id           = reader.GetInt32(reader.GetOrdinal("Id"));
                            suplier.DisplayName  = reader[reader.GetOrdinal("DisplayName")] as string;
                            suplier.Address      = reader[reader.GetOrdinal("Address")] as string;
                            suplier.Phone        = reader[reader.GetOrdinal("Phone")] as string;
                            suplier.Email        = reader[reader.GetOrdinal("Email")] as string;
                            suplier.MoreInfo     = reader[reader.GetOrdinal("MoreInfo")] as string;
                            suplier.ContractDate = reader.GetDateTime(reader.GetOrdinal("ContractDate"));
                            list.Add(suplier);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.Write(e.Message.ToString());
                return(null);
            }
            return(list);
        }
Ejemplo n.º 2
0
        public ActionResult Save(Suplier suplier)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new SuplierFormViewModel
                {
                    Suplier = suplier
                };
                return(View("SuplierForm", viewModel));
            }
            if (suplier.Id == 0)
            {
                _context.Supliers.Add(suplier);
            }
            else
            {
                var suplierInDb = _context.Supliers
                                  .Single(s => s.Id == suplier.Id);

                suplierInDb.DisplayName  = suplier.DisplayName;
                suplierInDb.Addresss     = suplier.Addresss;
                suplierInDb.ContractDate = suplier.ContractDate;
                suplierInDb.Email        = suplier.Email;
                suplierInDb.MoreInfo     = suplier.MoreInfo;
                suplierInDb.PhoneNumber  = suplier.PhoneNumber;
            }

            _context.SaveChanges();
            return(RedirectToAction("Index", "Suplier"));
        }
Ejemplo n.º 3
0
        public int AddSuplier(Suplier suplier)
        {
            int        result = 1;
            SqlCommand cmd;

            cmd             = new SqlCommand("USP_INSERT_SUPLIER", _conn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@nvcIDSuplier", suplier.IdSuplier);
            cmd.Parameters.AddWithValue("@nvcDisplayName", suplier.DisplayName);
            cmd.Parameters.AddWithValue("@nvcAdd", suplier.Add);
            cmd.Parameters.AddWithValue("@nvcPhone", suplier.Phone);
            cmd.Parameters.AddWithValue("@nvcMail", suplier.Email);

            _conn.Open();
            int check = cmd.ExecuteNonQuery();

            if (check != 1)
            {
                result = check;
            }
            _conn.Close();

            return(result);
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtAdress.Text != "" &&
                txtCompany.Text != "" &&
                txtEmail.Text != "" &&
                txtFirstName.Text != "" &&
                txtLastName.Text != "" &&
                txtPhone.Text != "" &&
                ImpCatDwn.selectedIndex != -1)
            {
                try
                {
                    if (btnAdd.Text == "Update")
                    {
                        var supl     = _UnitOfWork.Supplier.Find(Convert.ToInt16(lblId.Text));
                        var category = ImpCatDwn.selectedValue;
                        supl.Company   = txtCompany.Text;
                        supl.FirstName = txtFirstName.Text;
                        supl.LastName  = txtLastName.Text;
                        supl.Phone     = Convert.ToInt32(txtPhone.Text);
                        supl.Email     = txtEmail.Text;
                        supl.Adress    = txtAdress.Text;
                        supl.Category  = ParseEnum <Suplier.Cat>(category);
                        _UnitOfWork.Supplier.InsertOrUpdate(supl);
                        _UnitOfWork.Complete();

                        this.Hide();
                    }

                    else
                    {
                        var category = ImpCatDwn.selectedValue;
                        var Suplier  = new Suplier
                        {
                            Company   = txtCompany.Text,
                            FirstName = txtFirstName.Text,
                            LastName  = txtLastName.Text,
                            Phone     = Convert.ToInt32(txtPhone.Text),
                            Email     = txtEmail.Text,
                            Adress    = txtAdress.Text,
                            Category  = ParseEnum <Suplier.Cat>(category)
                        };

                        _UnitOfWork.Supplier.InsertOrUpdate(Suplier);
                        _UnitOfWork.Complete();

                        this.Hide();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                } /**/
            }
            else
            {
                MessageBox.Show("Looks Like You Miseed Something. Check All Text Boxes Are Filled ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
 public SuplierViewModel()
 {
     LoadSupliers();
     selectedSuplier      = new Suplier();
     DeleteSuplierCommand = new MyICommand(OnDelete, CanDelete);
     UpdateSuplierCommand = new MyICommand(OnUpdateSuplier, CanUpdateSuplier);
     AddSuplierCommand    = new MyICommand(OnAddSuplier, CanAddSuplier);
 }
Ejemplo n.º 6
0
        private void listSuplier(Suplier request)
        {
            DataSet data = MSuplier.getListSuplier(request);

            DBList            = data.Tables[0];
            DGList.DataSource = DBList;
            headerList();
        }
Ejemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Suplier suplier = db.supliers.Find(id);

            db.supliers.Remove(suplier);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
        void tampilSuplier(Suplier request)
        {
            DataSet data = MSuplier.getSuplier(request);

            DSuplier = data.Tables[0];
            DGMasterSuplier.DataSource = DSuplier;
            headerSuplier();
        }
Ejemplo n.º 9
0
        public ActionResult OfSuplieResult(Suplier suplier)
        {
            var item = from b in _context.Objectsses.Include(u => u.Unit).Include(s => s.Suplier)
                       where b.SuplierId == suplier.Id
                       select b;

            return(View("OfSuplier", item));
        }
Ejemplo n.º 10
0
 private void DataGridSupliers_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (OrderView != null)
     {
         Suplier suplier = (Suplier)DataGridSupliers.SelectedItem;
         OrderView.SuplierId.Text   = Convert.ToString(suplier.SuplierId);
         OrderView.SuplierName.Text = suplier.Name;
         this.Close();
     }
 }
Ejemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "SuplierID,SuplierName,Adress,Phone")] Suplier suplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(suplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(suplier));
 }
Ejemplo n.º 12
0
        public ActionResult Create([Bind(Include = "SuplierID,SuplierName,Adress,Phone")] Suplier suplier)
        {
            if (ModelState.IsValid)
            {
                db.supliers.Add(suplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(suplier));
        }
Ejemplo n.º 13
0
        // GET: /Suplier/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Suplier suplier = db.supliers.Find(id);

            if (suplier == null)
            {
                return(HttpNotFound());
            }
            return(View(suplier));
        }
Ejemplo n.º 14
0
        public SupplierViewModel()
        {
            List = new ObservableCollection <Suplier>(DataProvider.Ins.DB.Supliers);// hiển thị danh sách

            AddCommand = new RelayCommand <object>((p) =>
            {
                if (string.IsNullOrEmpty(DisplayName))
                {
                    return(false);
                }

                var displayList = DataProvider.Ins.DB.UserRoles.Where(x => x.DisplayName == DisplayName);
                if (displayList == null || displayList.Count() == 0) //điều kiện để nhấn dc button
                {
                    return(true);
                }

                return(false);
            }, (p) =>
            {
                var role = new Suplier()
                {
                    DisplayName = DisplayName
                };
                DataProvider.Ins.DB.Supliers.Add(role);
                DataProvider.Ins.DB.SaveChanges();// cập nhật trên db

                List.Add(role);
            });

            EditCommand = new RelayCommand <object>((p) =>
            {
                if (SelectedItem == null)
                {
                    return(false);
                }
                return(true);
            }, (p) =>
            {
                var role         = DataProvider.Ins.DB.Supliers.Where(x => x.Id == SelectedItem.Id).SingleOrDefault();//lấy ra id tương ứng
                role.DisplayName = DisplayName;
                role.Id          = Id;

                DataProvider.Ins.DB.SaveChanges();

                DisplayName = SelectedItem.DisplayName;
                Id          = SelectedItem.Id;
            });
        }
        public bool Delete([FromBody] Suplier input)
        {
            try
            {
                Expression <Func <Suplier, object> >[] properties =
                    new Expression <Func <Suplier, object> >[] { x => x.IsDeleted, x => x.ModifiedBy, x => x.ModifiedOn };

                input.IsDeleted = true;
                _supOpp.UpdateColumn(input, properties);
            }
            catch (Exception ex)
            {
            }
            return(true);
        }
        static void Main(string[] args)
        {
            Suplier sup = new Suplier()
            {
                CustomerID = 10, CustomerName = " Surendar", Department = "Technical"
            };

            var supdata = sup.ShowData();

            Console.WriteLine(supdata);

            var Benefits = sup.GetBenefits(30, 10000);

            Console.WriteLine("Benefits : {0}", Benefits);

            Console.ReadKey();
        }
 public Suplier Save([FromBody] Suplier input)
 {
     try
     {
         if (input.Id == 0)
         {
             input = _supOpp.Add(input);
         }
         else
         {
             input = _supOpp.Update(input);
         }
     }
     catch (Exception ex)
     {
     }
     return(input);
 }
Ejemplo n.º 18
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            FiledValid();
            this.DialogResult = DialogResult.OK;
            if (Action.Equals("edit"))
            {
                var suplier = db.Supliers.SingleOrDefault(x => x.Id == Id);

                suplier.DisplayName  = txtName.Text;
                suplier.TaxCode      = txtTaxCode.Text;
                suplier.AcountNumber = txtAccountNumber.Text;
                suplier.Phone        = txtPhone.Text;
                suplier.Email        = txtEmail.Text;
                suplier.Adress       = txtAdress.Text;
                suplier.ContractDate = txtContractDate.Value;
                suplier.MoreInfo     = txtMoreInfo.Text;
                suplier.Status       = chkSatus.Checked;
                db.SubmitChanges();
                this.Close();
            }
            else
            {
                Suplier suplier = new Suplier();
                suplier.DisplayName  = txtName.Text;
                suplier.TaxCode      = txtTaxCode.Text;
                suplier.AcountNumber = txtAccountNumber.Text;
                suplier.Phone        = txtPhone.Text;
                suplier.Email        = txtEmail.Text;
                suplier.Adress       = txtAdress.Text;
                suplier.ContractDate = txtContractDate.Value;
                suplier.MoreInfo     = txtMoreInfo.Text;
                suplier.Status       = chkSatus.Checked;
                db.Supliers.InsertOnSubmit(suplier);

                db.SubmitChanges();
                this.Close();
            }
        }
 public SuplierViewModel()
 {
     List          = new ObservableCollection <Suplier>(DataProvider.Ins.DB.Supliers);
     _ContractDate = DateTime.Now;
     #region Add
     AddCommand = new RelayCommand <object>((p) =>
     {
         if (string.IsNullOrWhiteSpace(DisplayName) || ContractDate == null)
         {
             return(false);
         }
         var displayList = DataProvider.Ins.DB.Supliers.Where(x => x.DisplayName == DisplayName);
         if (displayList == null || displayList.Count() != 0)
         {
             return(false);
         }
         return(true);
     }, (p) =>
     {
         var Suplier = new Suplier()
         {
             DisplayName = DisplayName.Trim(), Phone = Phone, Address = Address, Email = Email, ContractDate = ContractDate, MoreInfo = MoreInfo
         };
         DataProvider.Ins.DB.Supliers.Add(Suplier);
         DataProvider.Ins.DB.SaveChanges();
         List.Add(Suplier);
         Reset();
     });
     #endregion
     #region Edit
     EditCommand = new RelayCommand <object>((p) =>
     {
         if (SelectedItem == null || string.IsNullOrWhiteSpace(DisplayName))
         {
             return(false);
         }
         return(true);
     }, (p) =>
     {
         var Suplier          = DataProvider.Ins.DB.Supliers.Where(x => x.Id == SelectedItem.Id).SingleOrDefault();
         Suplier.Phone        = Phone;
         Suplier.DisplayName  = DisplayName.Trim();
         Suplier.Address      = Address;
         Suplier.Email        = Email;
         Suplier.ContractDate = ContractDate;
         Suplier.MoreInfo     = MoreInfo;
         DataProvider.Ins.DB.SaveChanges();
         Reset();
     });
     #endregion
     #region Sort
     SortIdCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortDisplayNameCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortAddressCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Address", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Address", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortPhoneCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Phone", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Phone", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortOutputPriceCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("OutputPrice", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("OutputPrice", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortEmailCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Email", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Email", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortMoreInfoCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("MoreInfo", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("MoreInfo", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortContractDateCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(List);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("ContractDate", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("ContractDate", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     #endregion
 }
Ejemplo n.º 20
0
        private void guna2Button5_Click(object sender, EventArgs e)
        {
            Color DefaultBorderTxt = Color.FromArgb(213, 218, 223);

            string id    = txtIdNCCtab5.Text;
            string name  = txtNCCtab5.Text;
            string add   = txtAddNCCtab5.Text;
            string phone = txtPhoneNCCtab5.Text;
            string email = txtEmailNCCtab5.Text;

            if (id.Equals("") || name.Equals("") || add.Equals("") || phone.Equals("") || email.Equals(""))
            {
                MessageBox.Show("Hãy điền đầy đủ thông tin nhà cung cấp", "My Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (id.Equals(""))
                {
                    txtIdNCCtab5.BorderColor = System.Drawing.Color.Red;
                }
                else
                {
                    txtIdNCCtab5.BorderColor = DefaultBorderTxt;
                }
                if (name.Equals(""))
                {
                    txtNCCtab5.BorderColor = System.Drawing.Color.Red;
                }
                else
                {
                    txtNCCtab5.BorderColor = DefaultBorderTxt;
                }
                if (add.Equals(""))
                {
                    txtAddNCCtab5.BorderColor = System.Drawing.Color.Red;
                }
                else
                {
                    txtAddNCCtab5.BorderColor = DefaultBorderTxt;
                }
                if (phone.Equals(""))
                {
                    txtPhoneNCCtab5.BorderColor = System.Drawing.Color.Red;
                }
                else
                {
                    txtPhoneNCCtab5.BorderColor = DefaultBorderTxt;
                }
                if (email.Equals(""))
                {
                    txtEmailNCCtab5.BorderColor = System.Drawing.Color.Red;
                }
                else
                {
                    txtEmailNCCtab5.BorderColor = DefaultBorderTxt;
                }
            }
            else
            {
                txtIdNCCtab5.BorderColor    = DefaultBorderTxt;
                txtNCCtab5.BorderColor      = DefaultBorderTxt;
                txtAddNCCtab5.BorderColor   = DefaultBorderTxt;
                txtPhoneNCCtab5.BorderColor = DefaultBorderTxt;
                txtEmailNCCtab5.BorderColor = DefaultBorderTxt;

                Suplier suplier = new Suplier(id, name, add, phone, email);
                int     result  = Sbus.AddSuplier(suplier);
                if (result == 1)
                {
                    MessageBox.Show("Thêm Nhà cung cấp: " + id + " - " + name + " Thành công", "My Application", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    datagridNCC.Rows.Clear();
                    datagridNCC.Refresh();
                    loadDataInforNCC();
                }
                else
                {
                    MessageBox.Show("Thêm nhà cung cấp thất bại", "My Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 21
0
 public int AddSuplier(Suplier suplier)
 {
     return(dal.AddSuplier(suplier));
 }
Ejemplo n.º 22
0
 public void OnAddSuplier()
 {
     SelectedSuplier = new Suplier();
     OnPropertyChanged("Supliers");
 }