Пример #1
0
        private void PUpdateGrid()                              //Update Product Method
        {
            AllDataContext dc         = new AllDataContext();
            int            selectedId = Convert.ToInt32(listBox2.SelectedValue);
            FastFood       ff         = dc.FastFoods.Single(c => c.Id == selectedId);

            ff.Name = txtUpdatePName.Text;
            ff.Rate = txtUpdatePRate.Text;

            dc.SubmitChanges();
        }
Пример #2
0
        private void AddProduct()                       //Add Product Method
        {
            AllDataContext dc = new AllDataContext();
            FastFood       ff = new FastFood()
            {
                Name = txtPName.Text,
                Rate = txtPRate.Text
            };

            dc.FastFoods.InsertOnSubmit(ff);
            dc.SubmitChanges();
        }
Пример #3
0
        private void btnPDelete_Click(object sender, EventArgs e)   //Delete Product
        {
            AllDataContext dc         = new AllDataContext();
            int            selectedId = Convert.ToInt32(listBox2.SelectedValue);
            FastFood       ff         = dc.FastFoods.Single(c => c.Id == selectedId);

            dc.FastFoods.DeleteOnSubmit(ff);
            dc.SubmitChanges();
            txtUpdatePName.Text = txtUpdatePRate.Text = "";
            MessageBox.Show("Product Deleted Successfully!");
            PRefreshGrid();
            OPRefreshGrid();
        }
Пример #4
0
        private void btnDelete_Click(object sender, EventArgs e)    //Delete Customer
        {
            AllDataContext dc         = new AllDataContext();
            int            selectedId = Convert.ToInt32(listBox1.SelectedValue);
            Customer       cs         = dc.Customers.Single(c => c.Id == selectedId);

            dc.Customers.DeleteOnSubmit(cs);
            dc.SubmitChanges();
            MessageBox.Show("Customer Deleted Successfully!");
            RefreshGrid();
            POC();
            LGrid();
        }
Пример #5
0
        private void updateGrid()                                   //Customer's Update Method
        {
            AllDataContext dc         = new AllDataContext();
            int            selectedId = Convert.ToInt32(listBox1.SelectedValue);
            Customer       cs         = dc.Customers.Single(c => c.Id == selectedId);

            cs.Name         = txtUpdateName.Text;
            cs.MobileNumber = txtUpdateMobile.Text;
            cs.Address      = txtUpdateAddress.Text;
            cs.CNIC         = txtUpdateCNIC.Text;

            dc.SubmitChanges();
        }
Пример #6
0
        private void AddCustomer()                                   //Add Customer Method
        {
            AllDataContext dc = new AllDataContext();
            Customer       c  = new Customer()
            {
                Name         = txtName.Text,
                MobileNumber = txtMobile.Text,
                Address      = txtAddress.Text,
                CNIC         = txtCNIC.Text
            };

            dc.Customers.InsertOnSubmit(c);
            dc.SubmitChanges();
        }
Пример #7
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            if (!txtChequeNo.Text.Equals("") && !cbBankName.Text.Equals("") &&
                !txtBranch.Text.Equals("") && !txtAccountNo.Text.Equals(""))
            {
                AllDataContext dc = new AllDataContext();
                var            c  = new Cheque()
                {
                    ChequeNo  = Convert.ToInt32(txtChequeNo.Text),
                    BankName  = cbBankName.Text,
                    Branch    = txtBranch.Text,
                    AccountNo = txtAccountNo.Text,
                    Status    = cbStatus.Text
                };
                dc.Cheques.InsertOnSubmit(c);
                dc.SubmitChanges();
                txtChequeNo.Text = txtBranch.Text = txtAccountNo.Text = "";
                this.Hide();
            }
            else if (txtChequeNo.Text.Equals("") && cbBankName.Text.Equals("") &&
                     txtBranch.Text.Equals("") && txtAccountNo.Text.Equals(""))
            {
                MessageBox.Show("Please Fill Cheque Details");
            }

            else
            {
                if (txtChequeNo.Text.Equals(""))
                {
                    errorProvider1.SetError(txtChequeNo, "Cheque No. Required");
                }

                else if (cbBankName.Text.Equals(""))
                {
                    errorProvider1.SetError(cbBankName, "Select Bank Required");
                }

                else if (txtBranch.Text.Equals(""))
                {
                    errorProvider1.SetError(txtBranch, "Branch Address Required");
                }

                else if (txtAccountNo.Text.Equals(""))
                {
                    errorProvider1.SetError(txtAccountNo, "A/C Required");
                }
            }
        }
Пример #8
0
        private void addLedger()                            //Add Ledger Method
        {
            AllDataContext dc = new AllDataContext();
            var            z  = (from w in dc.GetTable <Customer>()
                                 where w.Name == txtCusName.Text
                                 select w.Id).SingleOrDefault();

            int?i = dc.Ledgers.Where(x => x.C_Id == z)
                    .Max(x => (int?)x.Id);

            var r = (from u in dc.GetTable <Ledger>()
                     where u.Id == i
                     select u.Balance).SingleOrDefault();

            //Ledger Start
            Ledger l = new Ledger();

            l.C_Id = q;
            l.O_Id = Convert.ToInt32(lblOId.Text);

            if (Convert.ToDouble(txtPAmount.Text) == Convert.ToDouble(lblTAmount.Text))
            {
                l.Balance = r;
            }

            else if (Convert.ToDouble(txtPAmount.Text) == 0)
            {
                l.Credit  = lblTAmount.Text;
                l.Balance = (Convert.ToDouble(r) + Convert.ToDouble(l.Credit)).ToString();
            }
            else if (Convert.ToDouble(txtPAmount.Text) < Convert.ToDouble(lblTAmount.Text))
            {
                double j = Convert.ToDouble(lblTAmount.Text) - Convert.ToDouble(txtPAmount.Text);
                l.Credit  = Convert.ToString(j);
                l.Balance = (Convert.ToDouble(r) + Convert.ToDouble(l.Credit)).ToString();
            }
            else
            {
                double j = Convert.ToDouble(txtPAmount.Text) - Convert.ToDouble(lblTAmount.Text);
                l.Debit   = Convert.ToString(j);
                l.Balance = (Convert.ToDouble(r) - Convert.ToDouble(l.Debit)).ToString();
            }
            dc.Ledgers.InsertOnSubmit(l);
            dc.SubmitChanges();
            //Ledger End
        }
Пример #9
0
        private void addOrder()                             //Add Order Method
        {
            AllDataContext dc = new AllDataContext();
            Ordr           o  = new Ordr();

            o.Id        = Convert.ToInt32(lblOId.Text);
            o.C_Id      = q;
            o.Amount    = lblTAmount.Text;
            o.OrderDate = label1.Text;
            if (radioButton1.Checked)
            {
                o.Payment = radioButton1.Text;
            }

            else if (radioButton2.Checked)
            {
                o.Payment = radioButton2.Text;
            }

            dc.Ordrs.InsertOnSubmit(o);
            dc.SubmitChanges();
            t = o.Id;
        }
Пример #10
0
        private void opDetails()                            //Add Order Product Details
        {
            if (txtd1.Text != "")
            {
                AllDataContext dc = new AllDataContext();
                PDetail        pd = new PDetail();
                pd.O_Id = Convert.ToInt32(lblOId.Text);
                int d1 = (from cu in dc.GetTable <FastFood>()
                          where cu.Name == txtd1.Text
                          select cu.Id).SingleOrDefault();
                pd.P_Id  = d1;
                pd.Kg    = txtq1.Text;
                pd.Price = txtp1.Text;

                dc.PDetails.InsertOnSubmit(pd);
                dc.SubmitChanges();
            }
            if (txtd2.Text != "")
            {
                AllDataContext dc = new AllDataContext();
                PDetail        pd = new PDetail();
                pd.O_Id = Convert.ToInt32(lblOId.Text);
                int d2 = (from cu in dc.GetTable <FastFood>()
                          where cu.Name == txtd2.Text
                          select cu.Id).SingleOrDefault();
                pd.P_Id  = d2;
                pd.Kg    = txtq2.Text;
                pd.Price = txtp2.Text;

                dc.PDetails.InsertOnSubmit(pd);
                dc.SubmitChanges();
            }
            if (txtd3.Text != "")
            {
                AllDataContext dc = new AllDataContext();
                PDetail        pd = new PDetail();
                pd.O_Id = Convert.ToInt32(lblOId.Text);
                int d3 = (from cu in dc.GetTable <FastFood>()
                          where cu.Name == txtd3.Text
                          select cu.Id).SingleOrDefault();
                pd.P_Id  = d3;
                pd.Kg    = txtq3.Text;
                pd.Price = txtp3.Text;

                dc.PDetails.InsertOnSubmit(pd);
                dc.SubmitChanges();
            }
            if (txtd4.Text != "")
            {
                AllDataContext dc = new AllDataContext();
                PDetail        pd = new PDetail();
                pd.O_Id = Convert.ToInt32(lblOId.Text);
                int d4 = (from cu in dc.GetTable <FastFood>()
                          where cu.Name == txtd4.Text
                          select cu.Id).SingleOrDefault();
                pd.P_Id  = d4;
                pd.Kg    = txtq4.Text;
                pd.Price = txtp4.Text;

                dc.PDetails.InsertOnSubmit(pd);
                dc.SubmitChanges();
            }
            if (txtd5.Text != "")
            {
                AllDataContext dc = new AllDataContext();
                PDetail        pd = new PDetail();
                pd.O_Id = Convert.ToInt32(lblOId.Text);
                int d5 = (from cu in dc.GetTable <FastFood>()
                          where cu.Name == txtd5.Text
                          select cu.Id).SingleOrDefault();
                pd.P_Id  = d5;
                pd.Kg    = txtq5.Text;
                pd.Price = txtp5.Text;

                dc.PDetails.InsertOnSubmit(pd);
                dc.SubmitChanges();
            }
            if (txtd6.Text != "")
            {
                AllDataContext dc = new AllDataContext();
                PDetail        pd = new PDetail();
                pd.O_Id = Convert.ToInt32(lblOId.Text);
                int d6 = (from cu in dc.GetTable <FastFood>()
                          where cu.Name == txtd6.Text
                          select cu.Id).SingleOrDefault();
                pd.P_Id  = d6;
                pd.Kg    = txtq6.Text;
                pd.Price = txtp6.Text;

                dc.PDetails.InsertOnSubmit(pd);
                dc.SubmitChanges();
            }
            if (txtd7.Text != "")
            {
                AllDataContext dc = new AllDataContext();
                PDetail        pd = new PDetail();
                pd.O_Id = Convert.ToInt32(lblOId.Text);
                int d7 = (from cu in dc.GetTable <FastFood>()
                          where cu.Name == txtd7.Text
                          select cu.Id).SingleOrDefault();
                pd.P_Id  = d7;
                pd.Kg    = txtq7.Text;
                pd.Price = txtp7.Text;

                dc.PDetails.InsertOnSubmit(pd);
                dc.SubmitChanges();
            }
            if (txtd8.Text != "")
            {
                AllDataContext dc = new AllDataContext();
                PDetail        pd = new PDetail();
                pd.O_Id = Convert.ToInt32(lblOId.Text);
                int d8 = (from cu in dc.GetTable <FastFood>()
                          where cu.Name == txtd8.Text
                          select cu.Id).SingleOrDefault();
                pd.P_Id  = d8;
                pd.Kg    = txtq8.Text;
                pd.Price = txtp8.Text;

                dc.PDetails.InsertOnSubmit(pd);
                dc.SubmitChanges();
            }
        }