Exemple #1
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();
                }
            }
        }
Exemple #2
0
        private void btnSet_Click(object sender, EventArgs e)
        {
            if (stocklist == null)
            {
                String  sellPrice;
                Boolean isValid = true;
                sellPrice = txtSellprice.Text;

                if (sellPrice.Equals("0"))
                {
                    MessageBox.Show("Enter Sell Price !");
                    isValid = false;
                }

                if (isValid)
                {
                    stockadd.bookListView.Items[index].SubItems[4].Text = sellPrice;
                }

                this.Close();
            }
            else
            {
                String  sellPrice;
                Boolean isValid = true;
                sellPrice = txtSellprice.Text;

                if (sellPrice.Equals("0") || sellPrice.Equals(null))
                {
                    MessageBox.Show("Enter Sell Price !");
                    isValid = false;
                }

                if (isValid)
                {
                    connection();
                    String     changePrice    = "UPDATE STOCK SET SELL_PRICE ='" + sellPrice + "' WHERE BOOK_ID ='" + bookid + "'";
                    SqlCommand changePricecmd = new SqlCommand(changePrice, consql);
                    changePricecmd.ExecuteNonQuery();
                    stocklist.refreshform();
                    MessageBox.Show("FINISH");
                    this.Close();
                }
            }
        }
Exemple #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            connection();
            String stockid, bookid, quantity, sellprice, strStock;
            String format = "0000000";

            bookid  = dtODT.Rows[cbOrderdetail.SelectedIndex][4].ToString();
            stockid = "S" + (int.Parse(bookid.Substring(1, (bookid.Length - 1))).ToString(format));

            quantity  = txtQty.Text;
            sellprice = txtSellprice.Text;

            String         test   = "SELECT BOOK_ID,BOOK_QTY FROM STOCK WHERE STOCK_ID = '" + stockid + "'";
            SqlDataAdapter daTest = new SqlDataAdapter(test, consql);
            DataSet        dsTest = new DataSet();//DataSet For OrderDetail

            daTest.Fill(dsTest, "Test");
            DataTable dtTest = new DataTable();

            dtTest = dsTest.Tables["Test"];
            int i = dtTest.Rows.Count;


            if (i == 0)
            {
                strStock = "INSERT INTO STOCK VALUES('" + stockid + "','" + bookid + "','" + quantity + "','" + CommonConstant.CREATED_BY + "','" + DateTime.Now + "','" + DateTime.Now + "')";
            }
            else
            {
                int qty = int.Parse(dtTest.Rows[0][1].ToString());
                quantity = (int.Parse(quantity) + qty).ToString();
                strStock = "UPDATE STOCK SET BOOK_QTY ='" + quantity + "'";
            }
            SqlCommand stockCmd = new SqlCommand(strStock, consql);

            stockCmd.ExecuteNonQuery();


            MessageBox.Show("FINISH");
            stocklist.refreshform();
            this.Close();
        }