Exemplo n.º 1
0
        private void stockdataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int i;

            i = stockdataGridView.CurrentRow.Index;

            SetSellprice setsell = new SetSellprice(this);
            String       stockid = stockdataGridView.Rows[i].Cells[0].Value.ToString();
            String       format  = "0000000";
            String       bookid  = "B" + (int.Parse(stockid.Substring(1, (stockid.Length - 1))).ToString(format));

            setsell.bookid            = bookid;
            setsell.txtBook.Text      = stockdataGridView.Rows[i].Cells[2].Value.ToString();
            setsell.txtSellprice.Text = stockdataGridView.Rows[i].Cells[4].Value.ToString();



            String         strPurprice = "SELECT BK_PURCHASE_PRICE FROM BOOK WHERE BOOK_ID = '" + bookid + "'";
            SqlDataAdapter daPurprice  = new SqlDataAdapter(strPurprice, consql);
            DataTable      dtPurprice  = new DataTable();

            daPurprice.Fill(dtPurprice);
            setsell.txtPurPrice.Text = dtPurprice.Rows[0].ItemArray[0].ToString();
            setsell.Show();
        }
Exemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            String  stockid, bookid, bookname, price, quantity, selPrice;
            String  format  = "0000000";
            Boolean isValid = true;

            for (int i = 0; i < bookListView.Items.Count; i++)
            {
                bookid   = bookListView.Items[i].SubItems[0].Text;
                bookname = bookListView.Items[i].SubItems[1].Text;
                price    = bookListView.Items[i].SubItems[2].Text;
                quantity = bookListView.Items[i].SubItems[3].Text;
                selPrice = bookListView.Items[i].SubItems[4].Text;

                if (selPrice.Equals("0"))
                {
                    SetSellprice setsell = new SetSellprice(this);
                    setsell.txtBook.Text     = bookname;
                    setsell.txtPurPrice.Text = price;
                    setsell.index            = i;
                    isValid = false; //
                    setsell.Show();
                }

                if (isValid)
                {
                    stockid = "S" + (int.Parse(bookid.Substring(1, (bookid.Length - 1))).ToString(format));
                    String         strQty = "SELECT BOOK_QTY FROM STOCK WHERE BOOK_ID = '" + bookid + "'";
                    SqlDataAdapter daQty  = new SqlDataAdapter(strQty, consql);
                    DataSet        dsQty  = new DataSet();
                    daQty.Fill(dsQty, "QTY");
                    DataTable dtQty = dsQty.Tables["QTY"];
                    String    addStock;
                    if (dtQty.Rows.Count > 0)
                    {
                        quantity = (int.Parse(quantity) + int.Parse(dtQty.Rows[0].ItemArray[0].ToString())).ToString();
                        addStock = "UPDATE STOCK SET BOOK_QTY ='" + quantity + "' WHERE BOOK_ID ='" + bookid + "'";
                    }
                    else
                    {
                        addStock = "INSERT INTO STOCK VALUES('" + stockid + "','" + bookid + "','" + quantity + "','" + selPrice + "','" + CommonConstant.CREATED_BY + "','" + DateTime.Now + "','" + DateTime.Now + "')";
                    }

                    SqlCommand stockcmd = new SqlCommand(addStock, consql);
                    stockcmd.ExecuteNonQuery();

                    MessageBox.Show("FINISH");
                    stocklist.refreshform();

                    String     updateOrder   = "UPDATE PURCHASE_ORDER SET ORDER_STATUS = 'Done' WHERE ORDER_ID = '" + cbOrderid.Text + "'";
                    SqlCommand upOrderstatus = new SqlCommand(updateOrder, consql);
                    upOrderstatus.ExecuteNonQuery();
                    this.Close();
                }
            }
        }