예제 #1
0
 private void barButtonItem4_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         if (!splash.IsSplashFormVisible)
         {
             //  splashScreenManager.ShowWaitForm();
             SplashScreenManager.ShowForm(this, typeof(frmWait), true, true);
         }
         statesplash = true;
         //     Thread t = new Thread(new ThreadStart(StartForm));
         //     t.Start();
         frmTangQuaKH f = new frmTangQuaKH();
         AddTabControl(f, "Tặng quà khách hàng");
         //     t.Abort();
         if (splash.IsSplashFormVisible || statesplash == true)
         {
             SplashScreenManager.CloseForm();
             statesplash = false;
         }
     }
     catch
     {
         if (splash.IsSplashFormVisible || statesplash == true)
         {
             SplashScreenManager.CloseForm();
             statesplash = false;
         }
     }
 }
예제 #2
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (lookUpEdit1.Text == "Mời chọn")
            {
                XtraMessageBox.Show("Bạn chưa chọn đợt tặng quà");
                return;
            }
            else
            {
                SplashScreenManager.ShowForm(this, typeof(frmWait2), true, true);
                a = true;
                //    Thread th = new Thread(new ThreadStart(StartForm));
                //    th.Start();
                frmTangQuaKH f = new frmTangQuaKH();
                try
                {
                    string    ten      = "";
                    string    text     = "";
                    int       selected = new int();
                    bool      check    = false;
                    ArrayList rows     = new ArrayList();
                    for (int i = 0; i < gridView1.SelectedRowsCount; i++)
                    {
                        if (gridView1.GetSelectedRows()[i] >= 0)
                        {
                            rows.Add(gridView1.GetDataRow(gridView1.GetSelectedRows()[i]));
                        }
                    }
                    for (int i = 0; i < rows.Count; i++)
                    {
                        DataRow r = (DataRow)rows[i];
                        object  t = r["KHID"];
                        object  q = r["A"];
                        try
                        {
                            cn.openconnection();
                            MySqlCommand cmd = new MySqlCommand();
                            cmd.CommandType = CommandType.Text;
                            string sql = "insert into tinhtrangtang(TinhTrang,tangqua_TangQuaID,khachhang_KHID) values(@tinhtrang,@tangquaid,@khid); ";
                            cmd.CommandText = sql;
                            cmd.Connection  = cn.conn;
                            cmd.Parameters.Add("@tinhtrang", MySqlDbType.VarChar).Value = q;
                            cmd.Parameters.Add("@tangquaid", MySqlDbType.Int32).Value   = lookUpEdit1.EditValue.ToString();
                            cmd.Parameters.Add("@khid", MySqlDbType.Int32).Value        = t;
                            //      cmd.Parameters.Add("@tenkh", MySqlDbType.VarChar).Value = txtHoten.Text;
                            MySqlCommand cmd2 = new MySqlCommand();
                            cmd2.CommandType = CommandType.Text;
                            cmd2.CommandText = "select khachhang.TenKH from khachhang where khachhang.KHID = '" + t + "' ";
                            cmd2.Connection  = cn.conn;
                            MySqlDataReader rd2 = cmd2.ExecuteReader();
                            if (rd2.Read())
                            {
                                ten = rd2.GetString(0);
                            }
                            rd2.Close();
                            if (cmd.ExecuteNonQuery() == 1)
                            {
                                //  XtraMessageBox.Show("Data Inserted");
                            }
                            else
                            {
                                XtraMessageBox.Show("Lưu thất bại");
                            }
                        }
                        catch
                        {
                            text += "Khách hàng: " + ten + " đã nhận quà đợt " + lookUpEdit1.Text + Environment.NewLine;
                            check = true;
                            continue;
                        }
                    }
                    SplashScreenManager.CloseForm();
                    a        = false;
                    selected = rows.Count;
                    if (selected == 0)
                    {
                        XtraMessageBox.Show("Bạn chưa chọn khách hàng");
                        return;
                    }
                    //   th.Abort();
                    if (check == true)
                    {
                        /*    if(text == "")
                         *  {
                         *      XtraMessageBox.Show("Đã lưu");
                         *      return;
                         *  }*/
                        string s = text;
                        XtraMessageBox.Show(text);
                    }
                    else
                    {
                        XtraMessageBox.Show("Đã lưu");
                    }
                }
                catch (Exception ex)
                {
                    if (a == true)
                    {
                        SplashScreenManager.CloseForm();
                        a = false;
                    }
                    XtraMessageBox.Show(ex.Message);
                }
                finally { cn.closeconnection();
                          cn.conn.Dispose(); }
            }
            //}
            //for (int i = 0; i < gridView1.RowCount; i++)
            //{
            //    //object tt = gridView1.GetRowCellValue(i, "0").ToString();
            //    string ht = gridView1.GetRowCellValue(i, "TenKH").ToString();
            //    string slgd = gridView1.GetRowCellValue(i, "SoLanGiaoDich").ToString();
            //    string ttgd = gridView1.GetRowCellValue(i, "TongTienGiaoDich").ToString();


            //}
        }