private void btnSave_Click(object sender, EventArgs e) { DataTable dtType = clsSELECT.TypeProduct("", this.cbbTypeProduct.Text.Trim()).Tables[0]; string Type_ID = dtType.Rows[0]["Type_ID"].ToString(); if (txtProductName.Text == "") { MessageBox.Show("กรุณาระบุชื่อสินค้าก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtID.Text == "") { MessageBox .Show ("กรุณาระบุรหัสสินค้าก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtGoodmin .Text == "") { MessageBox.Show("กรุณาระบุจุดสั่งซื้อของสินค้า!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { var product = new clsPRODUCT(); product.Product_ID = this.txtID.Text.Trim(); product.Type_ID = Type_ID; product.Product_Name = this.txtProductName.Text.Trim(); product.Good_Min = this.txtGoodmin.Text.Trim(); if (FUNCTION == "INSERT") { if (clsINSERT.PRODUCT(product) == true) { MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("ข้อมูลไม่ถูกต้อง", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { if (clsUPDATE.PRODUCT(product) == true) { MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("ข้อมูลไม่ถูกต้อง", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } this.Close(); }
public static Boolean PRODUCT(clsPRODUCT M) { try { StringBuilder sb = new StringBuilder(); sb.Remove(0, sb.ToString().Length); sb.Append(" DELETE "); sb.Append(" FROM PRODUCT "); sb.Append(" WHERE Product_ID = '" + M.Product_ID + "'"); clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString()); return true; } catch (Exception ex) { return false; throw ex; } }
public static Boolean PRODUCT(clsPRODUCT M) { try { StringBuilder sb = new StringBuilder(); sb.Remove(0, sb.ToString().Length); sb.Append(" UPDATE PRODUCT "); sb.Append(" SET Product_Name = '" + M.Product_Name + "' "); sb.Append(" ,Pricebuy = '" + M.Pricebuy + "' "); sb.Append(" ,Pricesale = '" + M.Pricesale + "'"); sb.Append(" ,Total = '" + M.Total + "'"); sb.Append(" ,Type_ID = '" + M.Type_ID + "' "); sb.Append(" ,Dealer_ID = '" + M.Dealer_ID + "' "); sb.Append(" WHERE Product_ID = '" + M.Product_ID + "' "); clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString()); return true; } catch (Exception ex) { return false; throw ex; } }
private void button1_Click(object sender, EventArgs e) { if (txtSale .Text == "") { MessageBox.Show("กรุณาระบุราคาขายสินค้าก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int a = Convert.ToInt32(txtSale.Text); int b = Convert.ToInt32(Math.Floor(Convert.ToDouble(txtPrice.Text))); if (a < b) { MessageBox.Show("ราคาทุนมากกกว่าราคาขาย!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { var Price = new clsPRODUCT(); Price.Product_ID = this.txtID.Text.Trim(); Price.Product_Name = this.txtProductName.Text.Trim(); Price.Pricesale = this.txtSale.Text.Trim(); if (action == "") { if (clsUPDATE.PRICESALE(Price) == true) { MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("ข้อมูลไม่ถูกต้อง", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void button2_Click(object sender, EventArgs e) { var Product = new clsPRODUCT(); Product.Product_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_ID"].Value.ToString().Trim(); Product.Product_Name = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_Name"].Value.ToString().Trim(); Product.Type_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Type_ID"].Value.ToString().Trim(); Product.Good_Min = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Good_min"].Value.ToString().Trim(); //dgvView.Columns ("Pricebuy").DefaultCellStyle.Format = "#,##0.00"; if (MessageBox.Show("ต้องการลบข้อมูลใช่หรือไม่", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (clsDELETE.PRODUCT (Product) == true) { MessageBox.Show("ลบข้อมูลเรียบร้อย", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("เกิดข้อผิดพลาดในการลบข้อมูล", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } btnSearch_Click(sender, e); } }
private void button2_Click(object sender, EventArgs e) { var Product = new clsPRODUCT(); Product.Product_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_ID"].Value.ToString().Trim(); Product.Product_Name = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Product_Name"].Value.ToString().Trim(); Product.Pricebuy = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Pricebuy"].Value.ToString().Trim(); Product.Pricesale = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Pricesale"].Value.ToString().Trim(); Product.Total = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Total"].Value.ToString().Trim(); Product.Dealer_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Dealer_ID"].Value.ToString().Trim(); Product.Type_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Type_ID"].Value.ToString().Trim(); if (MessageBox.Show("ต้องการลบข้อมูลใช่หรือไม่", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (clsDELETE.PRODUCT (Product) == true) { MessageBox.Show("DE OK", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("DE NOT OK", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } btnSearch_Click(sender, e); } }
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); } }
public static Boolean PRODUCT(clsPRODUCT M) { try { StringBuilder sb = new StringBuilder(); sb.Remove(0, sb.ToString().Length); sb.Append(" INSERT INTO PRODUCT "); sb.Append(" (Dealer_ID "); sb.Append(" ,Type_ID "); sb.Append(" ,Product_Name "); sb.Append(" ,Pricebuy "); sb.Append(" ,Pricesale "); sb.Append(" ,Total )"); sb.Append(" VALUES "); sb.Append(" ('" + M.Dealer_ID + "' "); sb.Append(" ,'" + M.Type_ID + "' "); sb.Append(" ,'" + M.Product_Name + "' "); sb.Append(" ,'" + M.Pricebuy + "' "); sb.Append(" ,'" + M.Pricesale + "' "); sb.Append(" ,'" + M.Total+ "') "); clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString()); return true; } catch (Exception ex) { return false; throw ex; } }
public static Boolean STOCK(clsPRODUCT S) { try { StringBuilder sb = new StringBuilder(); sb.Remove(0, sb.ToString().Length); sb.Append(" UPDATE PRODUCT "); sb.Append(" SET Total = '" + S.Total + "' "); sb.Append(" WHERE Product_ID = '" + S.Product_ID + "' "); clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString()); return true; } catch (Exception ex) { return false; throw ex; } }
private void btnSave_Click(object sender, EventArgs e) { DataTable dtType = clsSELECT.TypeProduct("", this.cbbTypeProduct.Text.Trim()).Tables[0]; string Type_ID = dtType.Rows[0]["Type_ID"].ToString(); DataTable dtDealer = clsSELECT.Dealer("", this.cbbDealer.Text.Trim()).Tables[0]; string Dealer_ID = dtDealer.Rows[0]["Dealer_ID"].ToString(); if (txtProductName .Text == "") { MessageBox.Show("กรุณาระบุชื่อตัวแทนจำหน่ายก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtCost .Text == "") { MessageBox.Show("กรุณาระบุราคาทุนก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtSele .Text == "") { MessageBox.Show("กรุณาระบุราคาขายก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtTotal.Text == "") { MessageBox.Show("กรุณาระบุจำนวนสินค้าในสต๊อกก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { try { var product = new clsPRODUCT(); product.Product_ID = this.txtID.Text.Trim(); product.Dealer_ID = Dealer_ID; product.Type_ID = Type_ID; product.Product_Name = this.txtProductName.Text.Trim(); product.Pricebuy = this.txtCost.Text.Trim(); product.Pricesale = this.txtSele.Text.Trim(); product.Total = this.txtTotal.Text.Trim(); if (FUNCTION == "INSERT") { if (clsINSERT.PRODUCT(product) == true) { MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("ข้อมูลไม่ถูกต้อง", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { if (clsUPDATE.PRODUCT(product) == true) { MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("ข้อมูลไม่ถูกต้อง", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }