private void button1_Click(object sender, EventArgs e)
        {
            string madePayments = MadePayment.Text;

            if (madePayments.Count() > 0)
            {
                if (madePayments.All(char.IsDigit))
                {
                    FaridiaIronStoreEntities   db          = new FaridiaIronStoreEntities();
                    Entity.SupplierPaymentMade paymentMade = new SupplierPaymentMade();
                    paymentMade.Date              = dateTimePicker1.Value;
                    paymentMade.SupplierId        = _supplierID;
                    paymentMade.StationSupplierId = _supplierStationId;
                    paymentMade.PaymentMade       = int.Parse(madePayments);
                    db.SupplierPaymentMades.Add(paymentMade);
                    db.SaveChanges();
                    MessageBox.Show("Payment Made");
                    MadePayment.Text = string.Empty;
                    RefreshPaymentMade();
                    totalPaymentsMade();
                    totalPaymentsToBepaid();
                    TotalRemainingDue();
                }
                else
                {
                    MessageBox.Show("Numbers Only");
                }
            }
            else
            {
                MessageBox.Show("Enter Value");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();

            if (textBox1.Text.Count() != 0 && textBox2.Text.Count() != 0 && textBox3.Text.Count() != 0 && textBox3.Text.Count() < 15)
            {
                string       userName     = textBox1.Text;
                string       password     = textBox2.Text;
                string       phone        = textBox3.Text;
                string       email        = textBox4.Text;
                string       designation  = textBox5.Text;
                Entity.Login existingUser = db.Logins.Where(aa => aa.UserName.Equals(userName)).FirstOrDefault();
                if (existingUser == null)
                {
                    Entity.Login login = new Entity.Login();
                    login.UserName    = userName;
                    login.Password    = password;
                    login.Phone       = phone;
                    login.Email       = email;
                    login.Designation = designation;
                    db.Logins.Add(login);
                    db.SaveChanges();
                    MessageBox.Show("User Added");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("UserName Already Exists");
                }
            }
            else
            {
                MessageBox.Show("Fill Empty Fields");
            }
        }
示例#3
0
        private int LoadPreviousBill()
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var OrderPaymentsDue        = db.OrderLines.Where(aa => aa.Order.CustomerId == customerId && aa.Order.StationCustomerId == stationCustomerId).Select(aa => aa.PricePerUnit * aa.WeightInKg).Sum();

            if (OrderPaymentsDue == null)
            {
                OrderPaymentsDue = 0;
            }

            int paymentmadeCount = db.OrderPaymentMades.Where(aa => aa.CustomerId == customerId && aa.StationCustomerId == stationCustomerId)
                                   .Select(aa => aa.PaymentMade).Count();

            double paymentsMade = 0;

            if (paymentmadeCount > 0)
            {
                paymentsMade = db.OrderPaymentMades.Where(aa => aa.CustomerId == customerId && aa.StationCustomerId == stationCustomerId)
                               .Select(aa => aa.PaymentMade).Sum();
            }



            OrderPaymentsDue -= paymentsMade;

            return((int)OrderPaymentsDue);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            string paymentToBePaid = PaymentToBePaid.Text;

            if (paymentToBePaid.Count() > 0)
            {
                if (paymentToBePaid.All(char.IsDigit))
                {
                    FaridiaIronStoreEntities  db      = new FaridiaIronStoreEntities();
                    Entity.SupplierDuePayment payment = new SupplierDuePayment();
                    payment.Date              = dateTimePicker2.Value;
                    payment.SupplierId        = _supplierID;
                    payment.StationSupplierId = _supplierStationId;
                    payment.AmountToBePaid    = int.Parse(paymentToBePaid);
                    db.SupplierDuePayments.Add(payment);
                    db.SaveChanges();
                    MessageBox.Show("AmountToBePaid Added");
                    PaymentToBePaid.Text = string.Empty;
                    RefreshAmountToPaid();
                    totalPaymentsMade();
                    totalPaymentsToBepaid();
                    TotalRemainingDue();
                }
                else
                {
                    MessageBox.Show("Numbers Only");
                }
            }
            else
            {
                MessageBox.Show("Enter Value");
            }
        }
示例#5
0
        private void button6_Click(object sender, EventArgs e)
        {
            string accountNo = AccountNo.Text;

            if (accountNo.Count() > 0)
            {
                if (dataGridView1.SelectedRows.Count != 0)
                {
                    DataGridViewRow row                       = dataGridView1.SelectedRows[0];
                    string          id                        = row.Cells["SupplierID"].Value.ToString();
                    List <string>   seperate                  = Helpers.StationIdHelper.SeperateStationId(id);
                    int             supplierID                = int.Parse(seperate[1]);
                    int             StationID                 = int.Parse(seperate[0]);
                    Entity.FaridiaIronStoreEntities db        = new FaridiaIronStoreEntities();
                    Entity.SupplierBankDetail       supplierb = new SupplierBankDetail();
                    supplierb.SupplierId            = supplierID;
                    supplierb.StationSupplierId     = StationID;
                    supplierb.StationSupplierBankId = (int)Station.StationId;
                    supplierb.AccountNo             = accountNo;
                    db.SupplierBankDetails.Add(supplierb);
                    db.SaveChanges();
                    MessageBox.Show("Account Added");
                    AccountNo.Text = string.Empty;
                    GetAccounts(id);
                }
            }
            else
            {
                MessageBox.Show("Enter Account Number");
            }
        }
        private void RefreshPaymentMade()
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var list = db.SupplierPaymentMades.Where(aa => aa.SupplierId == _supplierID && aa.StationSupplierId == _supplierStationId).Select(s => new { s.PaymentMade, s.Date }).ToList();

            dataGridView1.DataSource = list;
        }
        public void UploadNewCustomers()
        {
            FaridiaIronStoreEntities       dbLocal  = new FaridiaIronStoreEntities();
            FaridiaIronStoreServerEntities dbServer = new FaridiaIronStoreServerEntities();
            var newCustomers = dbLocal.Customers.Where(aa => aa.StatusCode == (int)LocalDBStatusCode.Added).ToList();

            var config         = new MapperConfiguration(cfg => cfg.CreateMap <Entity.Customer, ServerEntity.CustomerServer>());
            var mapper         = config.CreateMapper();
            var customerserver = mapper.Map <List <Entity.Customer>, List <ServerEntity.CustomerServer> >(newCustomers);

            customerserver.ForEach(aa => aa.StatusCode = (int)ServerDBStatusCode.Added_From_Shop);

            newCustomers.ForEach(aa => aa.StatusCode = (int)LocalDBStatusCode.Updated_On_Server);

            try
            {
                var localDBTransaction  = dbLocal.Database.BeginTransaction();
                var ServerDBTransaction = dbServer.Database.BeginTransaction();


                dbServer.CustomerServers.AddRange(customerserver);
                dbServer.SaveChanges();
                dbLocal.SaveChanges();


                localDBTransaction.Commit();
                ServerDBTransaction.Commit();
            }
            catch
            {
                throw;
            }
        }
示例#8
0
 private void button5_Click_1(object sender, EventArgs e)
 {
     if (AccountNo.Text.Count() != 0 && dataGridView2.SelectedRows.Count != 0)
     {
         DataGridViewRow rowBank               = dataGridView2.SelectedRows[0];
         string          SupplierbankIdC       = rowBank.Cells["ID"].Value.ToString();
         List <string>   seperate              = Helpers.StationIdHelper.SeperateStationId(SupplierbankIdC);
         int             SupplierbankId        = int.Parse(seperate[1]);
         int             STATIONSupplierbankId = int.Parse(seperate[0]);
         string          accountNo             = AccountNo.Text;
         if (accountNo.Count() > 0)
         {
             DataGridViewRow row        = dataGridView1.SelectedRows[0];
             string          seperateid = row.Cells["SupplierID"].Value.ToString();
             // List<string> seperatesupplierID = Helpers.StationIdHelper.SeperateStationId(seperateid);
             // int supplierID = int.Parse(seperatesupplierID[1]);
             //int StationID = int.Parse(seperatesupplierID[0]);
             Entity.FaridiaIronStoreEntities db        = new FaridiaIronStoreEntities();
             Entity.SupplierBankDetail       supplierb = db.SupplierBankDetails.Where(aa => aa.SupplierBankId == SupplierbankId && aa.StationSupplierBankId == STATIONSupplierbankId).FirstOrDefault();
             supplierb.AccountNo = accountNo;
             db.SaveChanges();
             MessageBox.Show("Account Edited");
             AccountNo.Text = string.Empty;
             GetAccounts(seperateid);
         }
     }
     else
     {
         MessageBox.Show("Select Account Number");
     }
 }
        private void button1_Click_1(object sender, EventArgs e)
        {
            string nameCompany = CompanyName.Text;
            string adress      = Adress.Text;
            string phoneNo     = Phone.Text;
            string city        = City.Text;

            Entity.FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            Entity.Supplier supplierExist      = db.Suppliers.Where(aa => aa.Name.Equals(nameCompany)).FirstOrDefault();
            if (supplierExist == null)
            {
                if (phoneNo.Count() > 0 && phoneNo.Count() < 20)
                {
                    Entity.Supplier supplier = new Entity.Supplier();
                    supplier.Name              = nameCompany;
                    supplier.Address           = adress;
                    supplier.Phone             = phoneNo;
                    supplier.City              = city;
                    supplier.StationSupplierId = (int)Station.StationId;
                    db.Suppliers.Add(supplier);
                    db.SaveChanges();
                    MessageBox.Show("Saved");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Enter Valid PhoneNo");
                }
            }
            else
            {
                MessageBox.Show("Supplier Already Exists");
            }
        }
示例#10
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (AccountNo.Text.Count() != 0 && dataGridView2.SelectedRows.Count != 0)
     {
         DataGridViewRow rowBank               = dataGridView2.SelectedRows[0];
         string          bankId                = (rowBank.Cells["ID"].Value.ToString());
         List <string>   seperate1             = Helpers.StationIdHelper.SeperateStationId(bankId);
         int             SupplierbankId        = int.Parse(seperate1[1]);
         int             STATIONSupplierbankId = int.Parse(seperate1[0]);
         DataGridViewRow row                = dataGridView1.SelectedRows[0];
         string          Supplierid         = (row.Cells["SupplierID"].Value.ToString());
         List <string>   seperate2          = Helpers.StationIdHelper.SeperateStationId(Supplierid);
         int             supplierID         = int.Parse(seperate2[1]);
         int             StationID          = int.Parse(seperate2[0]);
         Entity.FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
         var BANKiD = db.SupplierBankDetails.Where(aa => aa.SupplierBankId == SupplierbankId && aa.StationSupplierBankId == STATIONSupplierbankId).FirstOrDefault();
         if (MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             db.SupplierBankDetails.Remove(BANKiD);
             db.SaveChanges();
             MessageBox.Show("Account Deleted");
             AccountNo.Text = string.Empty;
             GetAccounts(Supplierid);
         }
         else
         {
             AccountNo.Text = string.Empty;
             GetAccounts(Supplierid);
         }
     }
     else
     {
         MessageBox.Show("Select Account Number");
     }
 }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (ExtraNameField.Text == null || ExtraNameField.Text == "")
            {
                MessageBox.Show("Please enter Name");
                return;
            }

            Item newExtra = new Item();

            newExtra.ItemName   = ExtraNameField.Text;
            newExtra.IsExtra    = true;
            newExtra.StatusCode = (int)LocalDBStatusCode.Added;

            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();

            db.Items.Add(newExtra);
            try
            {
                db.SaveChanges();
                MessageBox.Show("Added Successfully");
                this.Close();
            }
            catch (Exception ee)
            {
                MessageBox.Show("Failed to save item \n" + ee.Message);
            }
        }
        private void LoadButton_Click(object sender, EventArgs e)
        {
            var startDate = StartDateField.Value.Date;
            var endDate   = EndDateField.Value;

            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var orders = db.Orders.Where(aa => aa.OrderDate >= startDate && aa.OrderDate <= endDate).OrderBy(aa => aa.OrderDate).ToList();



            var orderDataGrid = orders.Select(aa => new
            {
                Order_Id       = StationIdHelper.StationIdJoined(aa.StationOrderId, aa.OrderId),
                Customer_Name  = aa.Customer.Name,
                Date           = aa.OrderDate,
                IsAdvanceOrder = IsAdvance(aa.IsAdvanceOrder),
                DeliveryDate   = DeliveryDate(aa),
                IsDelivered    = IsDelivered(aa),
                Total_Bill     = CalculateTotalBill(StationIdHelper.StationIdJoined(aa.StationOrderId, aa.OrderId))
            }
                                              ).ToList();


            dataGridView1.DataSource = orderDataGrid;
        }
示例#13
0
        private void AddOldPayment_Load(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var customer = db.Customers.Where(aa => aa.CustomerId == customerId && aa.StationCustomerId == stationCustomerId).FirstOrDefault();

            CustomerNameLabel.Text  = customer.Name;
            CustomerIdLabel.Text    = StationIdHelper.StationIdJoined(stationCustomerId, customerId);
            OldDuePaymentLabel.Text = LoadPreviousBill().ToString();
        }
示例#14
0
        private void EditCustomer_FormClosing(object sender, FormClosingEventArgs e)
        {
            FaridiaIronStoreEntities db1 = new FaridiaIronStoreEntities();
            var customers  = db1.Customers.OrderByDescending(aa => aa.CustomerId).Take(pageSize).ToList();
            var helper     = new Helpers.CustomerHelper();
            var customerss = helper.CustomerForDataGrid(customers);

            dataGridView1.DataSource = customerss;
            dataGridView1.DefaultCellStyle.ForeColor = System.Drawing.Color.Black;
        }
示例#15
0
        private void EditCustomer_Load(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var supplier = db.Customers.Where(a => a.CustomerId == _id && a.StationCustomerId == _customerStationID).FirstOrDefault();

            CompanyName.Text = supplier.Name.Trim();
            Phone.Text       = supplier.Phone.Trim();
            Adress.Text      = supplier.Address.Trim();
            City.Text        = supplier.City.Trim();
        }
        private void EditSupplier_Load(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var supplier = db.Suppliers.Include(aa => aa.SupplierBankDetails).Where(a => a.SupplierId == _id && a.StationSupplierId == _supplierStationID).FirstOrDefault();

            CompanyName.Text = supplier.Name.Trim();
            Phone.Text       = supplier.Phone.Trim();
            Adress.Text      = supplier.Address.Trim();
            City.Text        = supplier.City.Trim();
        }
示例#17
0
        private void button1_Click(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            int id = int.Parse(textBox6.Text);

            Entity.Login login = db.Logins.Find(id);
            db.Logins.Remove(login);
            db.SaveChanges();
            MessageBox.Show("User Deleted");
            this.Close();
        }
        private void totalPaymentsToBepaid()
        {
            int totalDueAmount             = 0;
            FaridiaIronStoreEntities  db   = new FaridiaIronStoreEntities();
            List <SupplierDuePayment> list = db.SupplierDuePayments.Where(aa => aa.SupplierId == _supplierID && aa.StationSupplierId == _supplierStationId).ToList();

            foreach (SupplierDuePayment payments in list)
            {
                totalDueAmount = totalDueAmount + payments.AmountToBePaid;
            }
            _totalAmountToBPaid = totalDueAmount;
        }
        private void totalPaymentsMade()
        {
            int totalDueAmount              = 0;
            FaridiaIronStoreEntities   db   = new FaridiaIronStoreEntities();
            List <SupplierPaymentMade> list = db.SupplierPaymentMades.Where(aa => aa.SupplierId == _supplierID && aa.StationSupplierId == _supplierStationId).ToList();

            foreach (SupplierPaymentMade payments in list)
            {
                totalDueAmount = totalDueAmount + payments.PaymentMade;
            }
            TotalPaymentsMade.Text = totalDueAmount.ToString();
        }
示例#20
0
        private void DeleteUser_Load(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var user = db.Logins.Find(_id);

            textBox1.Text = user.UserName;
            textBox2.Text = user.Password;
            textBox3.Text = user.Phone;
            textBox4.Text = user.Email;
            textBox5.Text = user.Designation;
            textBox6.Text = user.LoginId.ToString();
        }
        private void SuppliersPayments_Load(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var supplier = db.Suppliers.Where(aa => aa.SupplierId == _supplierID && aa.StationSupplierId == _supplierStationId).FirstOrDefault();

            SupplierID.Text   = Helpers.StationIdHelper.StationIdJoined(supplier.StationSupplierId, supplier.SupplierId);
            SupplierName.Text = supplier.Name;
            RefreshPaymentMade();
            RefreshAmountToPaid();
            totalPaymentsMade();
            totalPaymentsToBepaid();
            TotalRemainingDue();
        }
示例#22
0
        private void LoadDataToGrid()
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var UsersList = db.Logins.Select(s => new
            {
                LoginId     = s.LoginId,
                UserName    = s.UserName,
                Password    = s.Password,
                Phone       = s.Phone,
                Email       = s.Email,
                Designation = s.Designation
            }).ToList();

            dataGridView1.DataSource = UsersList;
        }
示例#23
0
        private void GetAccounts(string supplierId)
        {
            List <string> seperate   = Helpers.StationIdHelper.SeperateStationId(supplierId);
            int           supplierID = int.Parse(seperate[1]);
            int           StationID  = int.Parse(seperate[0]);

            AccountNo.Text = string.Empty;
            Entity.FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var accounts = db.SupplierBankDetails.Where(aa => aa.SupplierId == supplierID && aa.StationSupplierId == StationID).Select(s => new
            {
                ID        = s.StationSupplierBankId + "_" + s.SupplierBankId,
                AccountNo = s.AccountNo
            }).ToList();

            dataGridView2.DataSource = accounts;
        }
示例#24
0
        public static List <CustomersDropDown> GetCustomerForDropDown()
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var customers = db.Customers.ToList();

            List <CustomersDropDown> CustomerDropDownList = new List <CustomersDropDown>();


            foreach (var cust in customers)
            {
                CustomersDropDown custDown = new CustomersDropDown();
                custDown.CustomerName     = cust.Name.Trim();
                custDown.JoinedCustomerId = cust.StationCustomerId + "_" + cust.CustomerId;
                CustomerDropDownList.Add(custDown);
            }

            return(CustomerDropDownList);
        }
        private void Button_Click(object sender, EventArgs e)
        {
            string nameCompany          = CompanyName.Text;
            string adress               = Adress.Text;
            string phoneNo              = Phone.Text;
            string city                 = City.Text;
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();

            Entity.Supplier supplier = db.Suppliers.Where(a => a.SupplierId == _id && a.StationSupplierId == _supplierStationID).FirstOrDefault();
            //IronStore.EntityFramework.SupplierBankDetail supplierBank = new EntityFramework.SupplierBankDetail();
            //List<IronStore.EntityFramework.SupplierBankDetail> bankList = new List<SupplierBankDetail>();
            supplier.Name    = nameCompany;
            supplier.Address = adress;
            supplier.Phone   = phoneNo;
            supplier.City    = city;
            db.SaveChanges();
            MessageBox.Show("Updated");
            this.Close();
        }
        public static List <ItemDropDownList> GetOrderItems(Order order)
        {
            List <ItemDropDownList>  itemDropDownList = new List <ItemDropDownList>();
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var items = db.OrderLines.Where(aa => aa.OrderId == order.OrderId).Select(aa => aa.Item).ToList();

            foreach (var item in items)
            {
                if (item.IsExtra == false)
                {
                    ItemDropDownList item1 = new ItemDropDownList();
                    item1.ItemComplete = item.ItemName.Trim() + "  " + item.Sotar.Trim() + "  " + item.thickness.Trim() + " " + item.City.Trim();
                    item1.ItemId       = item.ItemId;
                    itemDropDownList.Add(item1);
                }
            }

            return(itemDropDownList);
        }
        public static List <ItemDropDownList> GetItemsList()
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var items = db.Items.Where(aa => aa.IsExtra == false).ToList();
            List <ItemDropDownList> ItemsDropDownList = new List <ItemDropDownList>();

            ItemDropDownList itemA = new ItemDropDownList();

            itemA.ItemComplete = "Select Item";
            itemA.ItemId       = 0;

            ItemsDropDownList.Add(itemA);

            foreach (var item in items)
            {
                ItemDropDownList item1 = new ItemDropDownList();

                if (item.Sotar == null && item.thickness == null)
                {
                    item1.ItemComplete = item.ItemName.Trim() + "  " + "  " + " " + item.City.Trim();
                }

                else if (item.thickness == null)
                {
                    item1.ItemComplete = item.ItemName.Trim() + "  " + item.Sotar.Trim() + "  " + " " + item.City.Trim();
                }

                else if (item.Sotar == null)
                {
                    item1.ItemComplete = item.ItemName.Trim() + "  " + "  " + item.thickness.Trim() + " " + item.City.Trim();
                }

                else
                {
                    item1.ItemComplete = item.ItemName.Trim() + "  " + item.Sotar.Trim() + "  " + item.thickness.Trim() + " " + item.City.Trim();
                }

                item1.ItemId = item.ItemId;
                ItemsDropDownList.Add(item1);
            }
            return(ItemsDropDownList);
        }
        public void DownloadNewCustomers()
        {
            FaridiaIronStoreEntities       dbLocal  = new FaridiaIronStoreEntities();
            FaridiaIronStoreServerEntities dbServer = new FaridiaIronStoreServerEntities();
            var newServerCustomers = dbServer.CustomerServers.Where(aa => aa.StatusCode == (int)ServerDBStatusCode.Added_From_Home).ToList();

            if (newServerCustomers.Count == 0)
            {
                return;
            }

            var config        = new MapperConfiguration(cfg => cfg.CreateMap <ServerEntity.CustomerServer, Entity.Customer>());
            var mapper        = config.CreateMapper();
            var customerLocal = mapper.Map <List <ServerEntity.CustomerServer>, List <Entity.Customer> >(newServerCustomers);

            newServerCustomers.ForEach(aa => aa.StatusCode = (int)ServerDBStatusCode.Updated_On_Both_Sides);

            customerLocal.ForEach(aa => aa.StatusCode = (int)LocalDBStatusCode.Updated_From_Server);

            try
            {
                var localDBTransaction  = dbLocal.Database.BeginTransaction();
                var ServerDBTransaction = dbServer.Database.BeginTransaction();


                dbLocal.Customers.SqlQuery("SET IDENTITY_INSERT [Customer] On");
                dbLocal.Customers.AddRange(customerLocal);
                dbLocal.SaveChanges();
                dbLocal.Customers.SqlQuery("SET IDENTITY_INSERT [Customer] Off");
                dbServer.SaveChanges();



                localDBTransaction.Commit();
                ServerDBTransaction.Commit();
            }
            catch
            {
                throw;
            }
        }
示例#29
0
        private void Supplier_Load(object sender, EventArgs e)
        {
            AccountNo.Text = string.Empty;
            Entity.FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var supplierList = db.Suppliers.Select(s => new
            {
                SupplierId = s.StationSupplierId.ToString() + "_" + s.SupplierId.ToString(),
                s.Name,
                s.Phone,
                s.City,
                s.Address
            }).ToList();

            dataGridView1.DataSource = supplierList;
            if (dataGridView1.SelectedRows.Count != 0)
            {
                DataGridViewRow row = dataGridView1.SelectedRows[0];
                string          id  = row.Cells["SupplierID"].Value.ToString();
                GetAccounts(id);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            string loginId     = textBox6.Text;
            string userName    = textBox1.Text;
            string password    = textBox2.Text;
            string phone       = textBox3.Text;
            string email       = textBox4.Text;
            string designation = textBox5.Text;
            int    id          = int.Parse(loginId);

            Entity.Login login = db.Logins.Where(a => a.LoginId == id).First();
            login.UserName    = userName;
            login.Password    = password;
            login.Phone       = phone;
            login.Email       = email;
            login.Designation = designation;
            db.SaveChanges();
            MessageBox.Show("User Updated");
            this.Close();
        }