Пример #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            InvoiceSellingDetails insd = new InvoiceSellingDetails();

            insd.InvoiceNo   = txtInvoiceNumber.Text;
            insd.InvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text);
            insd.CustomerId  = customerid;
            insd.GrandTotal  = Convert.ToDecimal(txtGrandTotal.Text);
            int k = blinsell.CreateSellingInvoice(insd);

            SellingDetails sellingDetails = new SellingDetails();

            for (int j = 0; j < dataGridView.Rows.Count; j++)
            {
                sellingDetails.InvoiceSellingId = k;
                sellingDetails.ProductId        = Convert.ToInt32(dataGridView.Rows[j].Cells["colProductId"].Value.ToString());
                sellingDetails.CategoryId       = Convert.ToInt32(dataGridView.Rows[j].Cells["colCategoryId"].Value.ToString());
                sellingDetails.Quantity         = Convert.ToInt32(dataGridView.Rows[j].Cells["colQuantity"].Value.ToString());
                sellingDetails.SellingPrice     = Convert.ToDecimal(dataGridView.Rows[j].Cells["colSellingPrice"].Value.ToString());
                sellingDetails.Total            = Convert.ToDecimal(dataGridView.Rows[j].Cells["colTotal"].Value.ToString());
                sellingDetails.InvoiceDate      = Convert.ToDateTime(txtInvoiceDate.Text);
                blselling.CreateSells(sellingDetails);
            }
            MessageBox.Show("Sells Done");
            dataGridView.Rows.Clear();
            i = 0;
            LoadInvoice();
        }
Пример #2
0
        public ClientProductsDetailPage(SellingDetails sellingDetails)
        {
            InitializeComponent();
            var clientViewModel = new ClientProductsDetailViewModel(Navigation);

            clientViewModel.SellingDetails = sellingDetails;
            BindingContext = clientViewModel;
        }
Пример #3
0
        public int CreateSells(SellingDetails sed)
        {
            SqlConnection con = new SqlConnection(@"Data Source=PRASHISH\SQLEXPRESS;Integrated Security=true; Database=BroadwayDB");
            SqlCommand    cmd = new SqlCommand("insert into tblSelling values(@a,@c,@d,@e,@f,@g,@h)", con);

            cmd.Parameters.AddWithValue("@a", sed.InvoiceSellingId);
            cmd.Parameters.AddWithValue("@c", sed.CategoryId);
            cmd.Parameters.AddWithValue("@d", sed.ProductId);
            cmd.Parameters.AddWithValue("@e", sed.Quantity);
            cmd.Parameters.AddWithValue("@f", sed.SellingPrice);
            cmd.Parameters.AddWithValue("@g", sed.InvoiceDate);
            cmd.Parameters.AddWithValue("@h", sed.Total);

            con.Open();
            int i = cmd.ExecuteNonQuery();

            con.Close();

            return(i);
        }
Пример #4
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            SellingDetails sellingdDetails = new SellingDetails();

            sellingdDetails.CategoryId   = Convert.ToInt32(cboCategory.SelectedIndex.ToString());
            sellingdDetails.ProductId    = productid;
            sellingdDetails.Quantity     = Convert.ToInt32(txtQuantity.Text);
            sellingdDetails.SellingPrice = Convert.ToDecimal(txtSellingPrice.Text);
            sellingdDetails.Total        = Convert.ToDecimal(txtTotal.Text);
            StockDetails std = bls.GetStockByProductId(sellingdDetails.ProductId);

            if (std.Quantity >= sellingdDetails.Quantity)
            {
                dataGridView.Rows.Add();
                dataGridView.Rows[i].Cells["colCategoryId"].Value   = cboCategory.SelectedValue.ToString();
                dataGridView.Rows[i].Cells["colProductId"].Value    = cboProduct.SelectedValue.ToString();
                dataGridView.Rows[i].Cells["colCategoryName"].Value = cboCategory.Text;
                dataGridView.Rows[i].Cells["colProductName"].Value  = cboProduct.Text;
                dataGridView.Rows[i].Cells["colQuantity"].Value     = txtQuantity.Text;
                dataGridView.Rows[i].Cells["colSellingPrice"].Value = txtSellingPrice.Text;
                dataGridView.Rows[i].Cells["colTotal"].Value        = txtTotal.Text;
                txtGrandTotal.Text        = (Convert.ToDecimal(txtGrandTotal.Text) + Convert.ToDecimal(txtTotal.Text)).ToString();
                sellingdDetails.ProductId = std.ProductId;
                std.Quantity = std.Quantity - sellingdDetails.Quantity;
                bls.UpdateStock(std);
                i++;
            }
            else
            {
                int t = Convert.ToInt32(std.Quantity);
                int q = Convert.ToInt32(sellingdDetails.Quantity);
                MessageBox.Show("You have only " + t + " " + cboProduct.Text + " " + " stock. But have entered " + q);
            }
            cboProduct.Enabled   = false;
            txtQuantity.Text     = "";
            txtSellingPrice.Text = "";
        }