Esempio n. 1
0
        private void btn_Luu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string error    = "";
            bool   isUpdate = false;

            if (_listUpdate.Count > 1)
            {
                foreach (int id in _listUpdate)
                {
                    KhachHang kh = new KhachHang();
                    kh.id_khachhang = int.Parse(gridView1.GetRowCellValue(id, "id_khachhang").ToString());
                    kh.tenkh        = gridView1.GetRowCellValue(id, "tenkh").ToString();
                    kh.sdt          = gridView1.GetRowCellValue(id, "sdt").ToString();
                    kh.diachi       = gridView1.GetRowCellValue(id, "diachi").ToString();

                    if (!_kh_Bll.KiemTraSDTTonTai(kh.sdt, kh.id_khachhang))
                    {
                        _kh_Bll.CapNhatKhachHang(kh);
                        isUpdate = true;
                    }
                    else
                    {
                        if (error == "")
                        {
                            error = kh.tenkh;
                        }
                        else
                        {
                            error += " | " + kh.tenkh;
                        }
                    }
                }
            }
            if (isUpdate == true)
            {
                if (error.Length == 0)
                {
                    Notifications.Success("Cập dữ liệu thành công.");
                }
                else
                {
                    Notifications.Error("Có lỗi xảy ra khi cập nhật dữ liệu. Các khách hàng chưa được cập nhật (" + error + "). Lỗi: Số điện thoại đã tồn tại.");
                }
            }
            else
            {
                Notifications.Error("Có lỗi xảy ra khi cập nhật dữ liệu. Lỗi: Số điện thoại đã tồn tại.");
            }
            btn_Luu.Enabled = false;
            LoadDataSource();
        }