Пример #1
0
        private void btnOrder_Click(object sender, EventArgs e) //Add Receipt
        {
            if (radioButton1.Checked || radioButton2.Checked &&
                !txtPAmount.Text.Equals("") && !txtCusName.Text.Equals(""))
            {
                AllDataContext dc = new AllDataContext();
                q = (from cu in dc.GetTable <Customer>()
                     where cu.Name == txtCusName.Text
                     select cu.Id).SingleOrDefault();

                addOrder();
                opDetails();
                addLedger();
                ORefreshGrid();
                CRefreshGrid();
                LRefreshGrid();
                LGrid();

                txtd1.Text                                      = txtd2.Text = txtd3.Text = txtd4.Text =
                    txtd5.Text                                  = txtd6.Text = txtd7.Text = txtd8.Text =
                        txtq1.Text                              = txtq2.Text = txtq3.Text = txtq4.Text =
                            txtq5.Text                          = txtq6.Text = txtq7.Text = txtq8.Text =
                                txtr1.Text                      = txtr2.Text = txtr3.Text = txtr4.Text =
                                    txtr5.Text                  = txtr6.Text = txtr7.Text = txtr8.Text =
                                        txtp1.Text              = txtp2.Text = txtp3.Text = txtp4.Text =
                                            txtp5.Text          = txtp6.Text = txtp7.Text = txtp8.Text =
                                                txtCusName.Text = txtPAmount.Text = "";
                MessageBox.Show("New Receipt Added Successfully");
                lblOId.Text = (Convert.ToInt32(lblOId.Text) + 1).ToString();
            }
            else
            {
                MessageBox.Show("Please Fill receipt Information!");
            }
        }
Пример #2
0
        private void CGrid()                            //Customer's DataGridView
        {
            AllDataContext dc = new AllDataContext();
            var            q  = from cu in dc.GetTable <Customer>()
                                select cu;

            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.ColumnCount         = 4;

            dataGridView1.Columns[0].Name             = "name";
            dataGridView1.Columns[0].HeaderText       = "Customer Name";
            dataGridView1.Columns[0].DataPropertyName = "Name";

            dataGridView1.Columns[1].Name             = "mobilenumber";
            dataGridView1.Columns[1].HeaderText       = "Mobile Number";
            dataGridView1.Columns[1].DataPropertyName = "MobileNumber";

            dataGridView1.Columns[2].Name             = "address";
            dataGridView1.Columns[2].HeaderText       = "Address";
            dataGridView1.Columns[2].DataPropertyName = "Address";

            dataGridView1.Columns[3].Name             = "cnic";
            dataGridView1.Columns[3].HeaderText       = "CNIC";
            dataGridView1.Columns[3].DataPropertyName = "CNIC";

            dataGridView1.DataSource = q;

            var CustomerName =
                from cu in dc.Customers
                select new { cu.Name, cu.Id };

            listBox1.DataSource    = CustomerName;
            listBox1.DisplayMember = "Name";
            listBox1.ValueMember   = "Id";
        }
Пример #3
0
        private void ORGrid()                       //Product's DataGridView
        {
            AllDataContext dc = new AllDataContext();
            var            q  = from cu in dc.GetTable <OrView>()
                                select cu;

            dataGridView3.AutoGenerateColumns = false;
            dataGridView3.ColumnCount         = 5;

            dataGridView3.Columns[0].Name             = "id";
            dataGridView3.Columns[0].HeaderText       = "Order No.";
            dataGridView3.Columns[0].DataPropertyName = "Id";

            dataGridView3.Columns[1].Name             = "cid";
            dataGridView3.Columns[1].HeaderText       = "Customer Name";
            dataGridView3.Columns[1].DataPropertyName = "Name";

            dataGridView3.Columns[2].Name             = "amount";
            dataGridView3.Columns[2].HeaderText       = "Amount";
            dataGridView3.Columns[2].DataPropertyName = "Amount";

            dataGridView3.Columns[3].Name             = "OrderDate";
            dataGridView3.Columns[3].HeaderText       = "Order Date";
            dataGridView3.Columns[3].DataPropertyName = "orderDate";

            dataGridView3.Columns[4].Name             = "Payment";
            dataGridView3.Columns[4].HeaderText       = "Payment";
            dataGridView3.Columns[4].DataPropertyName = "payment";

            dataGridView3.DataSource = q;
        }
Пример #4
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
        }
Пример #5
0
        private void RefreshGrid()                     //Show Customer In Grid After Add
        {
            AllDataContext dc = new AllDataContext();
            var            q  = from cu in dc.GetTable <Customer>()
                                select cu;

            dataGridView1.DataSource = q;

            var CustomerName =
                from cu in dc.Customers
                select new { cu.Name, cu.Id };

            listBox1.DataSource    = CustomerName;
            listBox1.DisplayMember = "Name";
            listBox1.ValueMember   = "Id";
        }
Пример #6
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();
            }
        }