Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("กรุณาระบุเหตุผลในการยกเลิกรายการ", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
            var Order = new clsORDER();
            Order.Order_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Order_ID"].Value.ToString().Trim();
            Order.DateSent = dgvView.Rows[dgvView.CurrentRow.Index].Cells["DateSent"].Value.ToString().Trim();
            Order.DateReceive = dgvView.Rows[dgvView.CurrentRow.Index].Cells["DateReceive"].Value.ToString().Trim();
            Order.Mem_ID = lblMID.Text.Trim();
            Order.note = dgvView.Rows[dgvView.CurrentRow.Index].Cells["note"].Value.ToString().Trim();
            Order.Status = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Status"].Value.ToString().Trim();

                var frm = new frmNote();
                frm.txtNote.Text = dgvView.Rows[dgvView.CurrentRow.Index].Cells["note"].Value.ToString().Trim();
                frm.txtID.Text = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Order_ID"].Value.ToString().Trim();
                frm.ShowDialog();

                if (clsUPDATE .ORDERCANCEL(Order) == true)
                {
                    MessageBox.Show("ยกเลิกรายการเรียบร้อยแล้ว", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("เกิดข้อผิดพลาด", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
            }
            btnSearch_Click( sender,  e);
        }
Ejemplo n.º 2
0
        public static Boolean ORDER(clsORDER  O)
        {
            try
             {
                 StringBuilder sb = new StringBuilder();

                 sb.Remove(0, sb.ToString().Length);
                 sb.Append(" DELETE ");
                 sb.Append(" FROM O_ORDER ");
                 sb.Append(" WHERE Order_ID = '" + O.Order_ID + "'");

                 clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());
                 return true;
             }
             catch (Exception ex) { return false; throw ex; }
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (txtNote.Text == "")
            {
                MessageBox.Show("กรุณาระบุเหตุผลในการยกเลิกรายการ!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                try
                {
                    var Note = new clsORDER();
                    Note.Order_ID = this.txtID .Text.Trim();
                    Note.note = this.txtNote.Text.Trim();
                        if (clsUPDATE.UPNOTE(Note) == true)
                        {
                            this.Close();
                        }
                    }

                catch (Exception ex) { MessageBox.Show(ex.Message); }
            }
        }
Ejemplo n.º 4
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("ต้องการบันทึกข้อมูลใช่หรือไม่", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
            var Order = new clsORDER();
            Order.Order_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Order_ID"].Value.ToString().Trim();
            Order.Product_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_ID"].Value.ToString().Trim();
            Order.Product_Name = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_Name"].Value.ToString().Trim();
            Order.Price = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Price"].Value.ToString().Trim();
            Order.Total = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Total"].Value.ToString().Trim();
              if (action1 == "")
                  foreach (DataGridViewRow row in dgvView.Rows)
                  {
                      //if (Convert.ToInt32(row.Cells["Totaol"].Value.ToString()))
                      //{

                      //}else{
                      StringBuilder sbUPTOTAL = new StringBuilder();
                      sbUPTOTAL.Append("UPDATE DETAIL_ORDER ");
                      sbUPTOTAL.Append("SET Total = '" + row.Cells["Total"].Value.ToString() + "' ");
                      sbUPTOTAL.Append(" WHERE  Order_ID = '" + row.Cells["Order_ID"].Value.ToString() + "'");
                      sbUPTOTAL.Append(" AND Product_ID = '" + row.Cells["Product_ID"].Value.ToString() + "' ");
                      clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sbUPTOTAL.ToString());
                      //}
                  }
                if (clsUPDATE.ORDEROK(Order) == true)
                {

                    MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                else
                {
                    MessageBox.Show("เกิดข้อผิดพลาด", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
            } btnSearch_Click(sender, e);
        }
Ejemplo n.º 5
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {

                var Order = new clsORDER();
                Order.Order_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Order_ID"].Value.ToString().Trim();
                Order.Product_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_ID"].Value.ToString().Trim();
                Order.Product_Name = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_Name"].Value.ToString().Trim();
                Order.Price = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Price"].Value.ToString().Trim();
                Order.Total = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Total"].Value.ToString().Trim();

                var Stock = new clsPRODUCT();
                Stock.Product_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_ID"].Value.ToString().Trim();
                Stock.Product_Name = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_Name"].Value.ToString().Trim();
                Stock.Total = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Total"].Value.ToString().Trim();

                if (MessageBox.Show("ต้องการบันทึกข้อมูลใช่หรือไม่", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {

                if (action == "")
                {  //รับสินค้า
                    StringBuilder sb = new StringBuilder();
                    sb.Append("INSERT INTO DELIVERY(DELIVERY_ID ,Dealer_ID ,DELIVERY_Date ,Mem_ID)");
                    sb.Append("VALUES (");
                    sb.Append(" '" + lbID.Text.Trim() + "' ");
                    sb.Append(" ,'" + txtDeler .Text.Trim() + "' ");
                    sb.Append(" ,'" + dtpDateReceive.Value.ToString("MM/dd/yyyy", cConfigAtt.formatEn) + "'");
                    sb.Append(" ,'" + lblMID.Text.Trim() + "' ) ");
                    clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());

                    StringBuilder sbDetail = new StringBuilder();

                    foreach (DataGridViewRow row in dgvView.Rows)
                    {  //รายละเอียดการรับ
                        sbDetail.Append(" INSERT INTO DETAIL_DELIVERY(DELIVERY_ID ,Product_ID,Price ,Total )");
                        sbDetail.Append(" VALUES( ");
                        sbDetail.Append(" '" + lbID.Text.Trim() + "' ");
                        sbDetail.Append(", '" + row.Cells["Product_ID"].Value.ToString() + "' ");
                        sbDetail.Append(", '" + row.Cells["Price"].Value.ToString() + "' ");
                        sbDetail.Append(", '" + row.Cells["TotalDerivery"].Value.ToString() + "' ");
                        sbDetail.Append(" ); ");

                        if (action1 == "") // เพิ่มสินค้าเข้าสต๊อก
                        {
                            StringBuilder sbUPSTOCK = new StringBuilder();
                            sbUPSTOCK.Append("update dbo.PRODUCT set Total =  ");
                            sbUPSTOCK.Append("Total + " + row.Cells["TotalDerivery"].Value.ToString());
                            sbUPSTOCK.Append(" where  Product_ID = '" + row.Cells["Product_ID"].Value.ToString() + "'" );
                            clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sbUPSTOCK.ToString());
                        }

                    }
                    clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sbDetail.ToString());

                }

                if (clsUPDATE.DERIVERYOK(Order) == true) // อัพเดดสถานะ
                {

                        MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                 }

                else
                {
                    MessageBox.Show("เกิดข้อผิดพลาด", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
            }
            }
            catch (Exception) { MessageBox.Show("เกิดข้อผิดพลาดในการรับสินค้า!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
        }
Ejemplo n.º 6
0
        public static Boolean ORDEROK1(clsORDER O)
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                sb.Remove(0, sb.ToString().Length);
                sb.Append(" UPDATE DETAIL_ORDER ");
                sb.Append(" SET Total =  '" + O.Total + "'  ");
                sb.Append(" WHERE  Order_ID =  '" + O.Order_ID + "'  ");
                sb.Append(" AND Product_ID = '"+O.Product_ID+"' ");
                clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());
                return true;

            }
            catch (Exception ex) { return false; throw ex; }
        }