Example #1
0
 private void dataGridView1_CelltClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         string id = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
         if (e.ColumnIndex == 7)
         {
             DialogResult dr = MessageBox.Show("คุณต้องการลบข้อมูลนี้หรือไม่ ?", "ลบข้อมุล", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
             if (dr == DialogResult.Yes)
             {
                 string       query = "update verify set status ='DELETE' WHERE ver_id = @id";
                 MySqlCommand cmd   = new MySqlCommand(query, conn);
                 cmd.Parameters.AddWithValue("@id", id);
                 conn.Open();
                 try
                 {
                     cmd.ExecuteNonQuery();
                     cmd.Parameters.Clear();
                     conn.Close();
                     this.RenderGrid();
                     MessageBox.Show("ลบข้อมูลเรียบร้อย");
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("เกิดข้อผิดพลาดในการลบข้อมูลเนื่องจาก : " + ex.Message);
                     conn.Close();
                 }
             }
         }
         if (e.ColumnIndex == 6)
         {
             VerifyAdd da = new VerifyAdd(this);
             da.ID = id;
             da.Show();
         }
         if (e.ColumnIndex == 8)
         {
             string[] data = new string[4];
             data[0] = id;
             PrintView rw = new PrintView("print_quotation", data);
             rw.Show();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Example #2
0
        private void dataGridView1_CelltClick(object sender, DataGridViewCellEventArgs e)
        {
            string id = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();

            if (e.ColumnIndex == 7)
            {
                PayAdd da = new PayAdd(this);
                da.ID = id;
                da.Show();
            }
            if (e.ColumnIndex == 6)
            {
                string[] data = new string[4];
                data[0] = id;
                PrintView rw = new PrintView("print_pay", data);
                rw.Show();
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            dateTimePicker1.Text = DateTime.Now.ToString("yyyy-MM-dd");
            long   ln = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            string id = this.id;


            string query = "REPLACE INTO pay (pay_id,pay_date,ver_id,price)" +
                           "VALUES(@id,NOW(),@ver_id,@price)";
            MySqlCommand cmd = new MySqlCommand(query, conn);

            cmd.Parameters.AddWithValue("@id", id);
            cmd.Parameters.AddWithValue("@ver_id", ver_id.Text);
            cmd.Parameters.AddWithValue("@price", hiddenval.Text);

            cmd.CommandText = query;
            conn.Open();
            cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
            conn.Close();

            string       query1 = "update verify set status ='PAY' where ver_id=@id";
            MySqlCommand cmd1   = new MySqlCommand(query1, conn);

            cmd1.Parameters.AddWithValue("@id", ver_id.Text);
            cmd1.CommandText = query1;
            conn.Open();
            cmd1.ExecuteNonQuery();
            cmd1.Parameters.Clear();
            conn.Close();

            MessageBox.Show("บันทึกข้อมูลเรียบร้อย");

            string[] data = new string[4];
            data[0] = id;
            PrintView rw = new PrintView("print_pay", data);

            rw.Show();

            this.Close();
            this.Form.RenderGrid();
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string cusid = "";

            if (cus_id.Text == "กรุณาเลือก")
            {
                MessageBox.Show("กรุณาเลือกลูกค้า");
            }
            else
            {
                string       selectOne = "SELECT * from customers WHERE fullname = @name LIMIT 1";
                MySqlCommand cmd1      = new MySqlCommand(selectOne, conn);
                cmd1.Parameters.AddWithValue("@name", cus_id.Text);
                cmd1.CommandText = selectOne;
                conn.Open();
                MySqlDataReader reader1 = cmd1.ExecuteReader();
                while (reader1.Read())
                {
                    cusid = reader1.GetString("cus_id");
                }
                conn.Close();

                string       id2      = "";
                string       query2   = "Select case when Max(substr(quo_id, -6)) + 1 is null then 'QUO-000001' else case when (Max(substr(quo_id, -6)) + 1) < 10 then CONCAT('QUO-00000',(Max(substr(quo_id, -6)) + 1)) else CONCAT('QUO-0000',(Max(substr(quo_id, -6)) + 1)) end end as MaxID from quotation";
                MySqlCommand cmdQuery = new MySqlCommand(query2, conn);
                cmdQuery.CommandText = query2;
                conn.Open();
                MySqlDataReader dr = cmdQuery.ExecuteReader();
                while (dr.Read())
                {
                    id2 = dr.GetString("MaxID");
                }
                conn.Close();


                string query11 = "REPLACE INTO quotation (quo_id,quo_date,ver_id,price)" +
                                 "VALUES(@id,NOW(),@ver_id,@price)";
                MySqlCommand cmd11 = new MySqlCommand(query11, conn);

                cmd11.Parameters.AddWithValue("@id", id2);
                cmd11.Parameters.AddWithValue("@price", this.hiddenval.Text);
                cmd11.Parameters.AddWithValue("@ver_id", ver_id.Text);

                cmd11.CommandText = query11;
                conn.Open();
                cmd11.ExecuteNonQuery();
                cmd11.Parameters.Clear();
                conn.Close();



                string query = "REPLACE INTO verify (ver_id,ver_date,status,all_price,veh_symtom,cus_id)" +
                               "VALUES(@id,NOW(),'QUOTATION',@sumtotal,@veh_symtom,@cus_id)";
                MySqlCommand cmd = new MySqlCommand(query, conn);
                //long ln = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                string id = this.id == "" ? null : this.id;

                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@sumtotal", this.hiddenval.Text);
                //cmd.Parameters.AddWithValue("@veh_id", veh_id.Text);
                //cmd.Parameters.AddWithValue("@veh_type", veh_type.Text);
                cmd.Parameters.AddWithValue("@veh_symtom", veh_symtom.Text);
                cmd.Parameters.AddWithValue("@cus_id", cusid);

                cmd.CommandText = query;
                conn.Open();
                cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();
                conn.Close();
                MessageBox.Show("บันทึกข้อมูลเรียบร้อย");

                string[] data = new string[4];
                data[0] = id2;
                PrintView rw = new PrintView("print_quotation", data);
                rw.Show();

                this.Close();
                this.Form.RenderGrid();
            }
        }