Esempio n. 1
0
        private void LoadGridView()
        {
            int id = Convert.ToInt32(lblId.Text);
            //row = Convert.ToInt32(foodGridView.CurrentRow.Index.ToString());

            FIlterFoodDetails foodItem1 = blf.GetFilterFoodItems().Where(sc => sc.Id == id).FirstOrDefault();
            int i = frm.dataGridView1.Rows.Count;

            ////dataGridView1.Rows.Clear();
            frm.dataGridView1.Rows.Add();
            frm.dataGridView1.Rows[i].Cells["ColSN"].Value   = frm.dataGridView1.Rows.Count;
            frm.dataGridView1.Rows[i].Cells["ColItem"].Value = foodItem1.FoodName;
            frm.dataGridView1.Rows[i].Cells["ColQty"].Value  = 1;
            ////dataGridView1.Rows[i].Cells["ColQty"].Value = (dataGridView1.Rows[i].Cells["ColQty"] as DataGridViewComboBoxCell).Items[0];
            int Qty = Convert.ToInt32(frm.dataGridView1.Rows[i].Cells["ColQty"].Value);

            frm.dataGridView1.Rows[i].Cells["ColRate"].Value = foodItem1.Price;
            int Rate  = Convert.ToInt32(frm.dataGridView1.Rows[i].Cells["ColRate"].Value);
            int Total = Qty * Rate;

            frm.dataGridView1.Rows[i].Cells["ColTotal"].Value = Total;
            //// foodGridView.Rows[e.RowIndex].Visible = false;

            //CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[foodGridView.DataSource];
            //currencyManager1.SuspendBinding();
            //foodGridView.Rows[row].Visible = false;
            //currencyManager1.ResumeBinding();



            //// foodGridView.Rows[row].Visible = false;
            ////foodGridView.CurrentRow.Visible = false;
            frm.dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = default;
        }
Esempio n. 2
0
        private void showData()
        {
            BLLFoodItem blf = new BLLFoodItem();
            List <FIlterFoodDetails> lstcd = blf.GetFilterFoodItems();

            foodGridView.DataSource                  = lstcd;
            foodGridView.Columns["Id"].Visible       = false;
            foodGridView.Columns["Discount"].Visible = false;
            for (int i = 0; i < foodGridView.Columns.Count; i++)
            {
                if (foodGridView.Columns[i] is DataGridViewImageColumn)
                {
                    ((DataGridViewImageColumn)foodGridView.Columns[i]).ImageLayout = DataGridViewImageCellLayout.Zoom;
                    break;
                }
            }
            DataGridViewRow row = foodGridView.RowTemplate;

            row.Height = 60;
        }
Esempio n. 3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            id1 = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            FIlterFoodDetails foodItem1 = blf.GetFilterFoodItems().Where(sc => sc.Id == id1).FirstOrDefault();

            sn = Convert.ToInt32(dataGridView1.CurrentRow.Index.ToString());
            int i   = dataGridView1.Rows.Count;
            int num = Convert.ToInt32(dataGridView1.Rows[sn].Cells["ColQty"].Value);

            if (dataGridView1.Columns[e.ColumnIndex].Name == "Add")
            {
                //int num= Convert.ToInt32(dataGridView1.Rows[sn].Cells["ColQty"].Value);

                //count++;

                num++;
                dataGridView1.Rows[sn].Cells["ColQty"].Value = num;
                int    Qty  = Convert.ToInt32(dataGridView1.Rows[sn].Cells["ColQty"].Value);
                double Rate = Convert.ToDouble(dataGridView1.Rows[sn].Cells["ColRate"].Value);

                double Total = Qty * Rate;
                double discountPercentage = Convert.ToDouble(foodItem1.Discount);
                double discountAmount     = (discountPercentage / 100) * Total;
                dataGridView1.Rows[sn].Cells["ColDiscount"].Value = discountAmount;

                dataGridView1.Rows[sn].Cells["ColTotal"].Value = Total;
            }
            if (dataGridView1.Columns[e.ColumnIndex].Name == "Delete")
            {
                if (num == 1)
                {
                    num = 1;
                }
                else
                {
                    num--;
                }
                dataGridView1.Rows[sn].Cells["ColQty"].Value = num;
                int    Qty  = Convert.ToInt32(dataGridView1.Rows[sn].Cells["ColQty"].Value);
                double Rate = Convert.ToDouble(dataGridView1.Rows[sn].Cells["ColRate"].Value);

                double Total = Qty * Rate;
                double discountPercentage = Convert.ToDouble(foodItem1.Discount);
                double discountAmount     = (discountPercentage / 100) * Total;
                dataGridView1.Rows[sn].Cells["ColDiscount"].Value = discountAmount;
                dataGridView1.Rows[sn].Cells["ColTotal"].Value    = Total;
            }
            if (dataGridView1.Columns[e.ColumnIndex].Name == "Action")
            {
                //if (i==1)
                //{
                if (MessageBox.Show("Are You Sure Want to Remove ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    dataGridView1.Rows.RemoveAt(sn);
                    // dataGridView1.Rows[sn].Cells["ColSN"].Value = dataGridView1.Rows.Count;
                }
            }
            double sum      = 0;
            double discount = 0;

            for (int j = 0; j < dataGridView1.Rows.Count; j++)
            {
                sum      = Convert.ToDouble(dataGridView1.Rows[j].Cells["ColTotal"].Value) + sum;
                discount = Convert.ToDouble(dataGridView1.Rows[j].Cells["ColDiscount"].Value) + discount;
            }


            labelSubTotal.Text = sum.ToString();
            lblDiscount.Text   = discount.ToString();
            double subTotalAfterGettingDiscount = sum - discount;
            double vatPercentage = Properties.Settings.Default.VAT;
            double vatAMt        = (vatPercentage / 100);

            lblVat.Text = (vatAMt * subTotalAfterGettingDiscount).ToString();
            double subTotal      = subTotalAfterGettingDiscount;
            double vat           = Convert.ToDouble(lblVat.Text);
            double serviceCharge = Properties.Settings.Default.ServiceCharge;
            //double discountAmt = discount;
            //double total1 = (subTotal - discount);
            double total = (subTotalAfterGettingDiscount + vat + serviceCharge);

            lblTotal.Text = total.ToString();
        }