Beispiel #1
0
        public static Boolean DEALERPRODUCT(clsDEALER  M)
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                sb.Remove(0, sb.ToString().Length);
                sb.Append(" INSERT INTO DETAIL_PRODUCT ");
                sb.Append(" (Dealer_ID ");
                sb.Append(" ,Type_ID ");
                sb.Append(" ,Product_ID ");
                sb.Append(" ,Price) ");
                sb.Append(" VALUES ");
                sb.Append(" ('" + M.Dealer_ID + "' ");
                //sb.Append(" ,'" + M.Dealer_Name + "' ");
                sb.Append(" ,'" + M.Type_ID + "' ");
                //sb.Append(" ,'" + M.Type_Name + "' ");
                sb.Append(" ,'" + M.Product_ID + "' ");
                sb.Append(" ,'" + M.Price + "') ");

                clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());
                return true;
            }
            catch (Exception ex) { return false; throw ex; }
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("กรุณาระบุชื่อตัวแทนจำหน่ายก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (txtTel.Text == "")
            {
                MessageBox.Show("กรุณาระบุหมายเลขโทรศัพท์ก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (txtAddress.Text == "")
            {
                MessageBox.Show("กรุณาระบุที่อยู่ก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                try
                {
                    var Dealer = new clsDEALER();
                    Dealer.Dealer_ID = this.txtID.Text.Trim();
                    Dealer.Dealer_Name = this.txtName.Text.Trim();
                    Dealer.Dealer_Tel = this.txtTel.Text.Trim();
                    Dealer.Dealer_Address = this.txtAddress.Text.Trim();

                    if (FUNCTION == "INSERT")
                    {
                        if (clsINSERT.DEALER(Dealer) == true)
                        {
                            MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("ข้อมูลไม่ถูกต้อง", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        if (clsUPDATE.DEALER(Dealer) == 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();
        }
Beispiel #3
0
        public static Boolean Dealer1(clsDEALER  M)
        {
            try
             {
                 StringBuilder sb = new StringBuilder();

                 sb.Remove(0, sb.ToString().Length);
                 sb.Append(" DELETE ");
                 sb.Append(" FROM DETAIL_PRODUCT ");
                 sb.Append(" WHERE Product_ID = '" + M.Dealer_ID + "'");

                 clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());
                 return true;
             }
             catch (Exception ex) { return false; throw ex; }
        }
Beispiel #4
0
        public static Boolean DEALER(clsDEALER  M)
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                sb.Remove(0, sb.ToString().Length);
                sb.Append(" UPDATE DEALER ");
                sb.Append(" SET Dealer_Name  =  '" + M.Dealer_Name + "' ");
                sb.Append(" ,Dealer_Tel  =  '" + M.Dealer_Tel + "'");
                sb.Append(" ,Dealer_Address  =  '" + M.Dealer_Address + "'");
                sb.Append(" WHERE  Dealer_ID =  '" + M.Dealer_ID + "' ");

                clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());
                return true;
            }
            catch (Exception ex) { return false; throw ex; }
        }
Beispiel #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataTable dtProduct = clsSELECT.PRODUCT("", this.cbbProduct.Text.Trim()).Tables[0];
            string Product_ID = dtProduct.Rows[0]["Product_ID"].ToString();

            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 (txtPrice.Text == "")
            {
                MessageBox.Show("กรุณาระบุราคาสินค้าก่อน!", "การดำเนินการ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                try
                {
                    var Dealer1 = new clsDEALER();
                    Dealer1.Dealer_ID = Dealer_ID;
                    Dealer1.Product_ID = Product_ID;
                    Dealer1.Type_ID = Type_ID;
                    Dealer1.Price = this.txtPrice.Text.Trim();

                    if (FUNCTION == "INSERT")
                    {
                        if (clsINSERT.DEALERPRODUCT(Dealer1) == true)
                        {
                            MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("ข้อมูลไม่ถูกต้อง", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
            } this.Close();
        }
Beispiel #6
0
        private void btnDProduct_Click(object sender, EventArgs e)
        {
            var Dealer1 = new clsDEALER ();
            Dealer1.Dealer_ID = dgvView1.Rows[dgvView1.CurrentRow.Index].Cells["Dealer_ID1"].Value.ToString().Trim();
            Dealer1.Type_ID = dgvView1.Rows[dgvView1.CurrentRow.Index].Cells["Type_ID"].Value.ToString().Trim();
            Dealer1.Product_ID = dgvView1.Rows[dgvView1.CurrentRow.Index].Cells["Product_ID"].Value.ToString().Trim();
            Dealer1.Price = dgvView1.Rows[dgvView1.CurrentRow.Index].Cells["Price"].Value.ToString().Trim();

            if (MessageBox.Show("ต้องการลบข้อมูลใช่หรือไม่", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (clsDELETE.Dealer1(Dealer1) == true)
                {
                    MessageBox.Show("ลบข้อมูลเรียบร้อยแล้ว", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("เกิดข้อผิดพลาด", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
            }
            //btnSearch_Click(sender, e);
        }
Beispiel #7
0
        private void btnDelete_Click_1(object sender, EventArgs e)
        {
            var Dealer = new clsDEALER ();
            Dealer.Dealer_ID = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Dealer_ID"].Value.ToString().Trim();
            Dealer.Dealer_Name = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Dealer_Name"].Value.ToString().Trim();
            Dealer.Dealer_Tel = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Dealer_Tel"].Value.ToString().Trim();
            Dealer.Dealer_Address = dgvView.Rows[dgvView.CurrentRow.Index].Cells["Dealer_Address"].Value.ToString().Trim();

            if (MessageBox.Show("ต้องการลบข้อมูลใช่หรือไม่", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (clsDELETE.DEALER(Dealer) == true)
                {
                    MessageBox.Show("ลบข้อมูลเรียบร้อยแล้ว", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("เกิดข้อผิดพลาด", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
            }
            btnSearch_Click(sender, e);
        }
Beispiel #8
0
        public static Boolean DEALER(clsDEALER  M)
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                sb.Remove(0, sb.ToString().Length);
                sb.Append(" INSERT INTO DEALER ");
                //sb.Append(" ( Dealer_ID ");
                sb.Append(" (Dealer_Name ");
                sb.Append(" ,Dealer_Tel ");
                sb.Append(" ,Dealer_Address )");
                sb.Append(" VALUES ");
                //sb.Append(" ('" + M.Dealer_ID + "' ");
                sb.Append(" ('" + M.Dealer_Name + "' ");
                sb.Append(" ,'" + M.Dealer_Tel + "' ");
                sb.Append(" ,'" + M.Dealer_Address + "') ");

                clsGlobal.SQLQUERY.MS_ExecuteNonQuery(sb.ToString());
                return true;
            }
            catch (Exception ex) { return false; throw ex; }
        }