Ejemplo n.º 1
0
        private void AddStoveandRegulator_Load(object sender, EventArgs e)
        {
            Location = new Point(-7, 50);
            int w = SystemInformation.VirtualScreen.Width + 14;
            int h = SystemInformation.VirtualScreen.Height - 43;

            Size = new Size(w, h);
            dataGridView1.DefaultCellStyle.Font = new Font("Microsoft Sans Serif", 10);
            using (StockMgntRef.StockMgntClient client = new StockMgntRef.StockMgntClient())
            {
                dataGridView1.DataSource = client.GetStoves();
                stoves = client.GetStoves().ToList();
                if (stoves.Count >= 10)
                {
                    textBox3.Enabled = false;
                    textBox4.Enabled = false;
                    textBox5.Enabled = false;
                    button3.Enabled  = false;
                }
                string[] stoveTypes = stoves.Where(x => x.Price != 0).Select(x => x.Product).ToArray();
                comboBox2.Items.AddRange(stoveTypes);
                comboBox1.Items.AddRange(stoveTypes);

                var reg = client.GetRegulators();
                roldQty = reg.Quentity;
                //textBox6.Text = roldQty.ToString();
                label16.Text = roldQty + " piece(s)";
            }
        }
        private void ViewStock_Load(object sender, EventArgs e)
        {
            Location = new Point(-7, 50);
            int w = SystemInformation.VirtualScreen.Width + 14;
            int h = SystemInformation.VirtualScreen.Height - 43;

            Size = new Size(w, h);

            dataGridView1.DefaultCellStyle.Font = new Font("Microsoft Sans Serif", 10);
            dataGridView2.DefaultCellStyle.Font = new Font("Microsoft Sans Serif", 10);
            using (StockMgntRef.StockMgntClient client = new StockMgntRef.StockMgntClient())
            {
                dataGridView1.DataSource = client.GetCylinders();
                dataGridView2.DataSource = client.GetStoves();
                var reg = client.GetRegulators();
                label3.Text += reg.Quentity + " piece(s)";
                label5.Text += reg.Price + " Rs.";
            }
        }
        private void SetPrice_Load(object sender, EventArgs e)
        {
            Location = new Point(-7, 50);
            int w = SystemInformation.VirtualScreen.Width + 14;
            int h = SystemInformation.VirtualScreen.Height - 43;

            Size = new Size(w, h);
            using (StockMgntRef.StockMgntClient client = new StockMgntRef.StockMgntClient())
            {
                cylinders = client.GetCylinders().ToList();
                string[] cyTypes = cylinders.Where(x => x.Price != 0).Select(x => x.CylinderType).ToArray();
                comboBox1.Items.AddRange(cyTypes);

                stoves = client.GetStoves().ToList();
                string[] stoveTypes = stoves.Where(x => x.Price != 0).Select(x => x.Product).ToArray();
                comboBox2.Items.AddRange(stoveTypes);

                var reg = client.GetRegulators();
                textBox3.Text = reg.Price.ToString();
            }
        }
        private void button5_Click(object sender, EventArgs e)
        {
            dataGridView3.Rows.Clear();
            string cname    = textBox1.Text.Trim();
            double totalAmt = 0;
            string product  = "";
            int    qty      = 0;

            if (cname.Length > 0)
            {
                int imageWidth, tbQty = 0;
                if (Int32.TryParse(textBox2.Text, out imageWidth))
                {
                    tbQty = imageWidth;
                }
                TransactionMgnt.TransactionMgntClient txClient = new TransactionMgnt.TransactionMgntClient();
                List <TransactionMgnt.GSTRates>       gstrates = txClient.GetGSTRates().ToList();
                if (tbQty > 0)
                {
                    StockMgntRef.StockMgntClient stockMgntClient = new StockMgntRef.StockMgntClient();
                    var reg      = stockMgntClient.GetRegulators();
                    int regStock = reg.Quentity;
                    if (regStock >= tbQty)
                    {
                        double          cgst = gstrates.Where(x => x.Comodity.Equals("Regulator")).FirstOrDefault().CGST;
                        double          sgst = gstrates.Where(x => x.Comodity.Equals("Regulator")).FirstOrDefault().SGST;
                        DataGridViewRow nrow = (DataGridViewRow)dataGridView3.Rows[0].Clone();
                        nrow.Cells[0].Value = "Regulator(s)";
                        nrow.Cells[1].Value = tbQty;
                        nrow.Cells[2].Value = reg.Price;
                        nrow.Cells[3].Value = (100 + cgst + sgst) * (reg.Price * tbQty) / 100;
                        totalAmt           += double.Parse(nrow.Cells[3].Value.ToString());
                        dataGridView3.Rows.Add(nrow);
                    }
                    else
                    {
                        MessageBox.Show("Not Enough Stock of Regulators!!!");
                    }
                }

                foreach (DataGridViewRow row1 in dataGridView1.Rows)
                {
                    if (row1.Cells[0].Value != null)
                    {
                        product = row1.Cells[0].Value.ToString();
                        if (int.Parse(row1.Cells[1].Value.ToString()) > 0)
                        {
                            var selectedStove = stoves.Where(x => x.Product.Equals(product)).FirstOrDefault();
                            if (selectedStove.Quentity >= qty)
                            {
                                qty = int.Parse(row1.Cells[1].Value.ToString());
                                double          cgst = gstrates.Where(x => x.Comodity.Equals("Stove")).FirstOrDefault().CGST;
                                double          sgst = gstrates.Where(x => x.Comodity.Equals("Stove")).FirstOrDefault().SGST;
                                DataGridViewRow nrow = (DataGridViewRow)dataGridView3.Rows[0].Clone();
                                nrow.Cells[0].Value = product;
                                nrow.Cells[1].Value = qty;
                                nrow.Cells[2].Value = selectedStove.Price;
                                nrow.Cells[3].Value = (100 + cgst + sgst) * (selectedStove.Price * qty) / 100;
                                totalAmt           += double.Parse(nrow.Cells[3].Value.ToString());
                                dataGridView3.Rows.Add(nrow);
                            }
                            else
                            {
                                MessageBox.Show("Not Enough Stock of Stove '" + product + "' !!!");
                            }
                        }
                    }
                }
                label7.Text = totalAmt.ToString();
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            string cname   = textBox1.Text.Trim();
            int    cmnum   = 0;
            string product = "";
            int    qty     = 0;

            if (cname.Length > 0)
            {
                int imageWidth, tbQty = 0;
                if (Int32.TryParse(textBox2.Text, out imageWidth))
                {
                    tbQty = imageWidth;
                }
                if (tbQty > 0)
                {
                    StockMgntRef.StockMgntClient stockMgntClient = new StockMgntRef.StockMgntClient();
                    int regStock = stockMgntClient.GetRegulators().Quentity;
                    if (regStock >= tbQty)
                    {
                        TransactionMgnt.TransactionMgntClient client = new TransactionMgnt.TransactionMgntClient();
                        cmnum = client.RegulatorTx(cname, tbQty);
                        //PrintBill();
                    }
                    else
                    {
                        MessageBox.Show("Not Enough Stock of Regulators!!!");
                    }
                }
                foreach (DataGridViewRow row1 in dataGridView1.Rows)
                {
                    if (row1.Cells[0].Value != null)
                    {
                        product = row1.Cells[0].Value.ToString();
                        if (int.Parse(row1.Cells[1].Value.ToString()) > 0)
                        {
                            int stoveStock = stoves.Where(x => x.Product.Equals(product)).FirstOrDefault().Quentity;
                            if (stoveStock >= qty)
                            {
                                qty = int.Parse(row1.Cells[1].Value.ToString());
                                TransactionMgnt.TransactionMgntClient client1 = new TransactionMgnt.TransactionMgntClient();
                                cmnum = client1.StoveTx(cname, product, qty, cmnum);
                            }
                            else
                            {
                                MessageBox.Show("Not Enough Stock of Stove '" + product + "' !!!");
                            }
                        }
                    }
                }
                if (cmnum > 0)
                {
                    textBox1.Text = "";
                    textBox2.Text = "";
                    dataGridView1.Rows.Clear();
                    MessageBox.Show("Transaction is done Successfully !!! \nCashmemo Number is " + cmnum);
                }

                TransactionMgnt.TransactionMgntClient txClient = new TransactionMgnt.TransactionMgntClient();
                List <TransactionMgnt.GSTRates>       gstrates = txClient.GetGSTRates().ToList();

                int f = 0;
                foreach (DataGridViewRow r in dataGridView1.Rows)
                {
                    if (r.Cells[1].Value != null)
                    {
                        if (int.Parse(r.Cells[1].Value.ToString()) != 0)
                        {
                            f = 1;
                            break;
                        }
                        else
                        {
                            f = 0;
                        }
                    }
                }
                if (tbQty > 0)
                {
                    f = 1;
                }
                if (f == 1)
                {
                    //MessageBox.Show("In Print");
                    PrintReceipt(cname, cmnum, stoves, dataGridView3, gstrates);
                }
                else
                {
                    MessageBox.Show("Can't Generate Invoice for zero Quentity !!!");
                }
            }
        }