Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var Cancel = new clsCancel();
                Cancel.Exp_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Exp_ID"].Value.ToString().Trim();
                Cancel.Product_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_ID"].Value.ToString().Trim();
                Cancel.Pricesale = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Pricesale"].Value.ToString().Trim();
                Cancel.Exp_Total = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Exp_Total"].Value.ToString().Trim();

                if (MessageBox.Show("ต้องการลบข้อมูลใช่หรือไม่", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (clsDELETE.DECANCEL(Cancel) == true)
                    {
                            StringBuilder sbUPSTOCK = new StringBuilder();
                            sbUPSTOCK.Append("update dbo.PRODUCT set Total =  ");
                            sbUPSTOCK.Append("Total + '" + Cancel.Exp_Total + "'");
                            sbUPSTOCK.Append(" where  Product_ID = '" + Cancel.Product_ID + "'");
                            clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sbUPSTOCK.ToString());

                        MessageBox.Show("ลบข้อมูลสำเร็จ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("ลบข้อมูลไม่สำเร็จ", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("เกิดข้อผิดพลาด!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            btnSearch_Click( sender,  e);
        }
Ejemplo n.º 2
0
        public static Boolean DECANCEL(clsCancel  C)
        {
            try
             {
                 StringBuilder sb = new StringBuilder();

                 sb.Remove(0, sb.ToString().Length);
                 sb.Append(" DELETE ");
                 sb.Append(" FROM DETAIL_EXPIRED ");
                 sb.Append(" WHERE Exp_ID = '" + C.Exp_ID + "'");
                 sb.Append(" AND Product_ID = '" + C.Product_ID + "'");

                 clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());
                 return true;
             }
             catch (Exception ex) { return false; throw ex; }
        }
Ejemplo n.º 3
0
        public static Boolean EXCANCEL(clsCancel c)
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                sb.Remove(0, sb.ToString().Length);
                sb.Append(" INSERT INTO DETAIL_EXPIRED    ");
                sb.Append(" ( Exp_ID ");
                sb.Append(" ,Product_ID ");
                sb.Append(" ,Exp_Total  ");
                sb.Append(" ,Exp_Note ) ");
                sb.Append(" VALUES ");
                sb.Append(" ('" + c.Exp_ID + "' ");
                sb.Append(" ,'" + c.Product_ID + "' ");
                sb.Append(" ,'" + c.Exp_Total + "' ");
                sb.Append(" ,'" + c.Exp_Note + "') ");

                clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());
                return true;
            }
            catch (Exception ex) { return false; throw ex; }
        }
Ejemplo n.º 4
0
        private void button5_Click(object sender, EventArgs e)
        {
            DataTable dt = clsSELECT.Cancel(this.lbID.Text.Trim(), this.txtPID.Text.Trim()).Tables[0];
            if (dt.Rows.Count < 0)
            {
                string ProductID = dt.Rows[0]["Product_ID"].ToString();
            }

             if (txtPID.Text.Trim() == "")
            {
                MessageBox.Show("กรุณระบุเบอร์ชื่อสินค้า!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
                 else if (txtTotal.Text.Trim() == "")
            {
                MessageBox.Show("กรุณระบุจำนวนสินค้า!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (txtNote.Text.Trim() == "")
            {
                MessageBox.Show("กรุณาระบุเหตุผลในการยกเลิกขาย!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
             else if (Convert.ToDecimal(txtTotal.Text) > Convert.ToDecimal(txtStock.Text))
             {
                 MessageBox.Show("จำนวนสินค้าที่ตัดจ่ายเกินจำนวนสินค้าที่มีในสต๊อก!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
            else
            {

                try
                {
                    var Canael = new clsCancel ();
                    Canael.Exp_ID = this.lbID.Text.Trim();
                    Canael.Product_ID = this.txtPID.Text.Trim();
                    Canael.Exp_Total = this.txtTotal .Text.Trim();
                    Canael.Exp_Note = this.txtNote .Text.Trim();

                    if (dt.Rows.Count == 0)
                    {
                        if (clsINSERT.EXCANCEL(Canael) == true)
                        {
                            StringBuilder sbUPSTOCK = new StringBuilder();
                            sbUPSTOCK.Append("update dbo.PRODUCT set Total =  ");
                            sbUPSTOCK.Append("Total - '" + txtTotal.Text.Trim() + "'");
                            sbUPSTOCK.Append(" where  Product_ID = '" + txtPID.Text.Trim() + "'");
                            clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sbUPSTOCK.ToString());
                        }
                        else
                        {
                            MessageBox.Show("ข้อมูลไม่ถูกต้อง", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

                    else
                    {
                        StringBuilder sbUP = new StringBuilder();
                        sbUP.Append("update DETAIL_EXPIRED set Exp_Total =  ");
                        sbUP.Append("Exp_Total + " + txtTotal.Text.Trim());
                        sbUP.Append(" where  Exp_ID = '" + lbID.Text.Trim() + "'");
                        sbUP.Append(" and  Product_ID = '" + txtPID.Text.Trim() + "'");
                        clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sbUP.ToString());

                        StringBuilder sbUPSTOCK = new StringBuilder();
                        sbUPSTOCK.Append("update dbo.PRODUCT set Total =  ");
                        sbUPSTOCK.Append("Total - '" + txtTotal.Text.Trim() + "'");
                        sbUPSTOCK.Append(" where  Product_ID = '" + txtPID.Text.Trim() + "'");
                        clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sbUPSTOCK.ToString());

                    }
                 }
               catch (Exception) { MessageBox.Show("เกิดข้อผิดพลาดในการตัดจ่ายสินค้า!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); }

                }

            btnSearch_Click(sender, e);
            this.lbID.Text = clsSELECT.strGenIDEXPIRED(); //เลขที่ตัดจ่าย
            this.txtPName.Clear();
            this.txtPID.Clear();
            this.txtNote.Clear();
            this.txtTotal.Clear();
        }