Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            String Confirm, strConfirm;

            if (rbProgress.Checked)
            {
                Confirm = "Progress";
            }
            else if (rbSuccess.Checked)
            {
                Confirm = "Success";
            }
            else
            {
                Confirm = "Cancel";
            }
            connection();
            strConfirm = "UPDATE PURCHASE_ORDER SET ORDER_STATUS='" + Confirm + "' WHERE ORDER_ID ='" + orderID + "'";
            SqlCommand mycmd = new SqlCommand(strConfirm, consql);

            mycmd.ExecuteNonQuery();
            MessageBox.Show(MessageConstant.SUCCESS_PROGRESS);
            purorlst.connection();
            purorlst.FillData();
            this.Close();
        }
Example #2
0
        private void btnOrder_Click(object sender, EventArgs e)
        {
            String orderid, pubid, orDate, dueDate, strorder, status;

            orderid = txtOrderNo.Text;
            pubid   = cbPublisher.SelectedValue.ToString();
            status  = "Progress";
            orDate  = DateTime.Now.ToString();
            dueDate = dtpDuedate.Text;
            Boolean isValid = true;

            if (purorderList.Items.Count > 0)
            {
                if (test.Equals(CommonConstant.DB_INSERT))
                {
                    strorder = "Insert into PURCHASE_ORDER Values('" + orderid + "','" + pubid + "','" + status + "','" + orDate + "','" + dueDate + "','" + CommonConstant.CREATED_BY + "','" + DateTime.Now + "','" + DateTime.Now + "')";
                    SqlCommand mycmd = new SqlCommand(strorder, consql);
                    mycmd.ExecuteNonQuery();
                }
                else if (test.Equals(CommonConstant.DB_UPDATE))
                {
                    strorder = "UPDATE PURCHASE_ORDER SET PUB_ID='" + pubid + "',ORDER_STATUS = '" + status + "',DUE_DATE = '" + dueDate + "',LAST_UPDATED_DATE = '" + DateTime.Now + "' WHERE ORDER_ID = '" + orderid + "'";
                    SqlCommand mycmd = new SqlCommand(strorder, consql);
                    mycmd.ExecuteNonQuery();
                }
            }
            else
            {
                MessageBox.Show(MessageConstant.PURCAHSE.ORDER_CONFIRM);
                isValid = false;
            }


            if (isValid)
            {
                purchaseorderlist.connection();
                purchaseorderlist.FillData();

                String bookid, quantity;

                for (int i = 0; i < purorderList.Items.Count; i++)
                {
                    String format = "000000";
                    bookid   = purorderList.Items[i].SubItems[0].Text;
                    quantity = purorderList.Items[i].SubItems[3].Text;
                    connection();

                    if (test.Equals(CommonConstant.DB_INSERT))
                    {
                        String     strOrDT = "Insert into ORDER_DETAIL Values('" + "OT" + (i + 1).ToString(format) + "','" + orderid + "','" + bookid + "','" + quantity + "','" + CommonConstant.CREATED_BY + "','" + DateTime.Now + "','" + DateTime.Now + "')";
                        SqlCommand OrDTcmd = new SqlCommand(strOrDT, consql);
                        OrDTcmd.ExecuteNonQuery();
                        // MessageBox.Show(CommonConstant.DB_INSERT);
                    }
                    else if (test.Equals(CommonConstant.DB_UPDATE))
                    {
                        String     ODTid   = "OT" + (i + 1).ToString(format);
                        String     strOrDT = "UPDATE ORDER_DETAIL SET BOOK_ID='" + bookid + "',QUANTITY ='" + quantity + "',STATUS = 'Progress',LAST_UPDATED_DATE = '" + DateTime.Now + "' WHERE ORDER_DT_ID='" + ODTid + "' AND ORDER_ID='" + orderid + "'";
                        SqlCommand OrDTcmd = new SqlCommand(strOrDT, consql);
                        OrDTcmd.ExecuteNonQuery();
                        //  MessageBox.Show(CommonConstant.DB_UPDATE);
                    }

                    cleartxt();
                }
                MessageBox.Show(MessageConstant.PURCAHSE.ORDER_FINISHED);
                this.Close();
            }
        }