示例#1
0
        private void LoadListKhachAo()
        {
            List <DanhBaKhachAo> lstKhachAo = new List <DanhBaKhachAo>();

            lstKhachAo = DanhBaKhachAo.GetDanhSachKhachAo();
            gridDanhMucKhachAo.DataSource = lstKhachAo;
        }
 /// <summary>
 /// Mo form KhachAo de edit
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void gridKhachAo_DoubleClick(object sender, EventArgs e)
 {
     gridKhachAo.SelectionMode = Janus.Windows.GridEX.SelectionMode.SingleSelection;
     if (gridKhachAo.SelectedItems.Count > 0)
     {
         GridEXRow     row        = ((GridEXSelectedItem)gridKhachAo.SelectedItems[0]).GetRow();
         DanhBaKhachAo objKhachAo = (DanhBaKhachAo)((GridEXSelectedItem)gridKhachAo.SelectedItems[0]).GetRow().DataRow;
         frmKhachAo    frm        = new frmKhachAo(objKhachAo, false);
         if (frm.ShowDialog(this) == DialogResult.OK)
         {
             objKhachAo = frm.GetKhachAo();
             frm.Dispose();
             //Insert DataBase
             if (!objKhachAo.Update())
             {
                 new MessageBox.MessageBoxBA().Show("Lỗi thêm mới khách ảo");
                 return;
             }
             else
             {
                 //Load lai grid
                 LoadListKhachAo();
             }
         }
         else
         {
             return;
         }
     }
 }
        private void ThemKhachAo()
        {
            DanhBaKhachAo objKhachAo = new DanhBaKhachAo(string.Empty, string.Empty, string.Empty);
            frmKhachAo    frm        = new frmKhachAo(objKhachAo, true);// them moi

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                objKhachAo = frm.GetKhachAo();
                //Insert DataBase
                if (StringTools.TrimSpace(objKhachAo.Name).Length <= 0)
                {
                    return;
                }

                if (StringTools.TrimSpace(objKhachAo.Address).Length <= 0)
                {
                    return;
                }

                if (StringTools.TrimSpace(objKhachAo.PhoneNumber).Length < 8)
                {
                    return;
                }
                if (!objKhachAo.Insert())
                {
                    new MessageBox.MessageBoxBA().Show("Lỗi thêm mới khách ảo");
                    return;
                }
                else
                {
                    //Load lai grid
                    LoadListKhachAo();
                }
            }
        }
示例#4
0
 private void gridViewDanhMucKhachAo_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         if (gridViewDanhMucKhachAo.SelectedRowsCount > 0)
         {
             DanhBaKhachAo objKhachAo = (DanhBaKhachAo)gridViewDanhMucKhachAo.GetFocusedRow();
             frmKhachAo    frm        = new frmKhachAo(objKhachAo, false);
             frm.ShowDialog(this);
             if (frm.IsSuccess)
             {
                 objKhachAo = frm.GetKhachAo();
                 frm.Dispose();
                 if (!objKhachAo.Update())
                 {
                     new MessageBox.MessageBoxBA().Show("Lỗi khi sửa khách ảo!");
                 }
                 else
                 {
                     LoadListKhachAo();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("gridViewDanhMucKhachAo_DoubleClick: ", ex);
     }
 }
示例#5
0
 private void XoaKhachAo()
 {
     try
     {
         if (gridViewDanhMucKhachAo.SelectedRowsCount > 0)
         {
             DanhBaKhachAo           objKhachAo = (DanhBaKhachAo)gridViewDanhMucKhachAo.GetFocusedRow();
             MessageBox.MessageBoxBA msg        = new MessageBox.MessageBoxBA();
             if (msg.Show(this, "Bạn có xóa khách ảo " + objKhachAo.Name + " không ?", "Xóa khách ảo", MessageBox.MessageBoxButtonsBA.OKCancel, MessageBox.MessageBoxIconBA.Question) == DialogResult.OK.ToString())
             {
                 if (!objKhachAo.Delete(objKhachAo.PhoneNumber))
                 {
                     new MessageBox.MessageBoxBA().Show("Lỗi khi xóa khách ảo!");
                 }
                 else
                 {
                     LoadListKhachAo();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("XoaKhachAo: ", ex);
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string strSQL = "";

                if (radDienThoai.Checked)
                {
                    strSQL = "SELECT * FROM  [dbo].[T_DANHBA_KhachAo] WHERE  PhoneNumber LIKE '%" + StringTools.TrimSpace(editThongTinTimKiem.Text) + "%'";
                }
                else if (radTen.Checked)
                {
                    strSQL = "SELECT * FROM  [dbo].[T_DANHBA_KhachAo] WHERE Name LIKE N'%" + StringTools.TrimSpace(editThongTinTimKiem.Text) + "%'";
                }
                else if (radDiaChi.Checked)
                {
                    strSQL = "SELECT * FROM  [dbo].[T_DANHBA_KhachAo] WHERE Address LIKE '%" + StringTools.TrimSpace(editThongTinTimKiem.Text) + "%'";
                }
                mListOfKhachAo    = DanhBaKhachAo.GetKhachAos(strSQL);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("btnSave_Click: ", ex);
            }
        }
        private void LoadListKhachAo()
        {
            List <DanhBaKhachAo> lstKhachAo = new List <DanhBaKhachAo>();

            lstKhachAo = DanhBaKhachAo.GetDanhSachKhachAo();

            gridKhachAo.DataMember = "ListOfKhachAo";
            gridKhachAo.SetDataBinding(lstKhachAo, "ListOfKhachAo");
        }
 /// <summary>
 /// Khoi tao mot doi tương DoiTac, o che do thêm mơi hay sửa đổi thông tin
 /// </summary>
 /// <param name="DoiTac"></param>
 /// <param name="boolAdd"></param>
 public frmKhachAo(DanhBaKhachAo KhachAo, bool boolAdd)
 {
     InitializeComponent();
     mIsAdd = boolAdd;
     if (boolAdd)
     {
         this.Text = "Thêm mới khách ảo";
     }
     else
     {
         this.Text = "Sửa đổi thông tin khách ảo";
         editSoDienThoai.Enabled = false;
     }
     mKhachAo = KhachAo;
 }
示例#9
0
 private void SuaKhachAo()
 {
     try
     {
         if (gridViewDanhMucKhachAo.SelectedRowsCount > 0)
         {
             DanhBaKhachAo objKhachAo = (DanhBaKhachAo)gridViewDanhMucKhachAo.GetFocusedRow();
             frmKhachAo    frm        = new frmKhachAo(objKhachAo, false);
             frm.ShowDialog(this);
             if (frm.IsSuccess)
             {
                 objKhachAo = frm.GetKhachAo();
                 if (StringTools.TrimSpace(objKhachAo.Name).Length <= 0)
                 {
                     return;
                 }
                 if (StringTools.TrimSpace(objKhachAo.Address).Length <= 0)
                 {
                     return;
                 }
                 if (StringTools.TrimSpace(objKhachAo.PhoneNumber).Length < 8)
                 {
                     return;
                 }
                 if (!objKhachAo.Update())
                 {
                     new MessageBox.MessageBoxBA().Show("Lỗi khi sửa khách ảo");
                 }
                 else
                 {
                     LoadListKhachAo();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("SuaKhachAo: ", ex);
     }
 }
        private void SuaKhachAo()
        {
            gridKhachAo.SelectionMode = Janus.Windows.GridEX.SelectionMode.SingleSelection;
            if (gridKhachAo.SelectedItems.Count > 0)
            {
                GridEXRow     row        = ((GridEXSelectedItem)gridKhachAo.SelectedItems[0]).GetRow();
                DanhBaKhachAo objKhachAo = (DanhBaKhachAo)((GridEXSelectedItem)gridKhachAo.SelectedItems[0]).GetRow().DataRow;
                frmKhachAo    frm        = new frmKhachAo(objKhachAo, false);
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    objKhachAo = frm.GetKhachAo();
                    if (StringTools.TrimSpace(objKhachAo.Name).Length <= 0)
                    {
                        return;
                    }

                    if (StringTools.TrimSpace(objKhachAo.Address).Length <= 0)
                    {
                        return;
                    }

                    if (StringTools.TrimSpace(objKhachAo.PhoneNumber).Length < 8)
                    {
                        return;
                    }
                    //Insert DataBase
                    if (!objKhachAo.Update())
                    {
                        new MessageBox.MessageBoxBA().Show("Lỗi thêm mới khách ảo");
                        return;
                    }
                    else
                    {
                        //Load lai grid
                        LoadListKhachAo();
                    }
                }
            }
        }
示例#11
0
        private void ThemKhachAo()
        {
            try
            {
                DanhBaKhachAo objKhachAo = new DanhBaKhachAo(string.Empty, string.Empty, string.Empty);
                frmKhachAo    frm        = new frmKhachAo(objKhachAo, true);// them moi
                frm.ShowDialog(this);
                if (frm.IsSuccess)
                {
                    objKhachAo = frm.GetKhachAo();
                    if (StringTools.TrimSpace(objKhachAo.Name).Length <= 0)
                    {
                        return;
                    }

                    if (StringTools.TrimSpace(objKhachAo.Address).Length <= 0)
                    {
                        return;
                    }

                    if (StringTools.TrimSpace(objKhachAo.PhoneNumber).Length < 8)
                    {
                        return;
                    }
                    if (!objKhachAo.Insert())
                    {
                        new MessageBox.MessageBoxBA().Show("Lỗi thêm mới khách ảo");
                    }
                    else
                    {
                        LoadListKhachAo();
                    }
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("ThemKhachAo: ", ex);
            }
        }
        private void XoaKhachAo()
        {
            gridKhachAo.SelectionMode = Janus.Windows.GridEX.SelectionMode.SingleSelection;
            if (gridKhachAo.SelectedItems.Count > 0)
            {
                GridEXRow               row        = ((GridEXSelectedItem)gridKhachAo.SelectedItems[0]).GetRow();
                DanhBaKhachAo           objKhachAo = (DanhBaKhachAo)((GridEXSelectedItem)gridKhachAo.SelectedItems[0]).GetRow().DataRow;
                MessageBox.MessageBoxBA msg        = new Taxi.MessageBox.MessageBoxBA();

                if (msg.Show(this, "Bạn có xóa khách ảo " + objKhachAo.Name + " không ?", "Xóa khách ảo", Taxi.MessageBox.MessageBoxButtonsBA.OKCancel, Taxi.MessageBox.MessageBoxIconBA.Question).ToString() == DialogResult.OK.ToString())
                {
                    if (!objKhachAo.Delete(objKhachAo.PhoneNumber))
                    {
                        new MessageBox.MessageBoxBA().Show("Lỗi thêm mới khách ảo");
                        return;
                    }
                    else
                    {
                        //Load lai grid
                        LoadListKhachAo();
                    }
                }
            }
        }
        /// <summary>
        /// Input : SoDienThoai
        /// Output
        ///     : KieuKhachHangGoiDen
        ///     : DiaChicuakhach hang
        ///  //Tim trong kho Khach VIP
        ///  Tim trong kho doi tac
        ///  Tim trong kho danh ba tam
        ///  Tim trong kho danh ba buu dien
        /// </summary>
        private string GetDiaChiGoiDen(string PhoneNumber, out KieuKhachHangGoiDen outKieuKhachHang, out string MaDoiTac)
        {
            if (StringTools.TrimSpace(PhoneNumber).Length <= 0)
            {
                outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
                MaDoiTac         = "";
                return(string.Empty);
            }

            string strDiaChiKhachAo = DanhBaKhachAo.GetDanhBa(DanhBa.GetSoDienThoaiToiThieu(PhoneNumber));

            if (strDiaChiKhachAo.Length > 0)
            {
                outKieuKhachHang = KieuKhachHangGoiDen.KhachHangKhongHieu;//khach ao
                MaDoiTac         = "";
                return(strDiaChiKhachAo);
            }

            // Tim kiem trong khach VIP (3_)
            DanhBaKhachQuen objKhachQuen = DanhBaKhachQuen.GetKhachQuen_Phones_Search(DanhBa.GetSoDienThoaiToiThieu(PhoneNumber));

            if (objKhachQuen != null && objKhachQuen.Name.Length > 0)
            {
                if (objKhachQuen.Type == 1)
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangVIP;
                }
                else if (objKhachQuen.Type > 1 && objKhachQuen.Rank == 1)
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangVang;
                }
                else if (objKhachQuen.Type > 1 && objKhachQuen.Rank == 2)
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBac;
                }
                else
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
                }
                MaDoiTac = objKhachQuen.MaKH;

                return(String.Format("[{0}]{1}", objKhachQuen.Name, objKhachQuen.Address));
            }

            // Tim kiem trong DOI TAC (2_)
            DoiTac objDoiTac = DoiTac.GetDoiTacByOPhoneNumber(DanhBa.GetSoDienThoaiToiThieu(PhoneNumber));

            if (objDoiTac != null)
            {
                outKieuKhachHang = KieuKhachHangGoiDen.KhachHangMoiGioi;
                MaDoiTac         = objDoiTac.MaDoiTac;
                g_kinhdo         = objDoiTac.KinhDo;
                g_vido           = objDoiTac.ViDo;
                return(objDoiTac.Name + "-" + objDoiTac.Address);
            }

            //Tim kiem trong danh ba dien thoai cua rieng cong ty (1_)
            string strDiaChiCuocGoiGanNhat = GetDiaChiCuaCuocGoiGanNhatTrongNgay(DanhBa.GetSoDienThoaiToiThieu(PhoneNumber));

            if (strDiaChiCuocGoiGanNhat.Length > 0)
            {
                outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
                MaDoiTac         = "";
                return(strDiaChiCuocGoiGanNhat);
            }

            // tim kiem trong danh ba cong ty
            string strDiaChiDanhBaCongTy = DanhBaCongTy.GetDanhBa(DanhBa.GetSoDienThoaiToiThieu(PhoneNumber));

            if (strDiaChiDanhBaCongTy.Length > 0)
            {
                outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;//khach ao
                MaDoiTac         = "";
                return(strDiaChiDanhBaCongTy);
            }

            //Tim kiem trong danh ba dien thoai (1_)
            outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
            MaDoiTac         = "";
            return(DanhBa.GetDanhBa(DanhBa.GetSoDienThoaiToiThieu(PhoneNumber)));
        }
 private void SetKhachAo(DanhBaKhachAo KhachAo)
 {
     editSoDienThoai.Text = KhachAo.PhoneNumber;
     editTen.Text         = KhachAo.Name;
     editDiaChi.Text      = KhachAo.Address;
 }
示例#15
0
        /// <summary>
        /// Input : SoDienThoai
        /// Output
        ///     : KieuKhachHangGoiDen
        ///     : DiaChicuakhach hang
        ///  //Tim trong kho Khach VIP
        ///  Tim trong kho doi tac
        ///  Tim trong kho danh ba tam
        ///  Tim trong kho danh ba buu dien
        /// </summary>
        private string GetDiaChiGoiDen(string phoneNumber, out KieuKhachHangGoiDen outKieuKhachHang, out string outMaDoiTac)
        {
            try
            {
                if (StringTools.TrimSpace(phoneNumber).Length <= 0)
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
                    outMaDoiTac      = "";
                    return(string.Empty);
                }
                //// xu ly co tong dai
                //if (PhoneNumber[0].ToString() == "5")
                //{
                //    PhoneNumber = PhoneNumber.Substring(1, PhoneNumber.Length - 1);
                //}

                string strDiaChiKhachAo = DanhBaKhachAo.GetDanhBa(DanhBa.GetSoDienThoaiToiThieu(phoneNumber));

                if (strDiaChiKhachAo.Length > 0)
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangKhongHieu;//khach ao
                    outMaDoiTac      = "";
                    return(strDiaChiKhachAo);
                }

                // Tim kiem trong khach VIP (3_)
                DanhBaKhachQuen objKhachQuen = DanhBaKhachQuen.GetKhachQuen_Phones_Search(DanhBa.GetSoDienThoaiToiThieu(phoneNumber));

                if (objKhachQuen != null && objKhachQuen.Name.Length > 0)
                {
                    if (objKhachQuen.Type == 1)
                    {
                        outKieuKhachHang = KieuKhachHangGoiDen.KhachHangVIP;
                    }
                    else if (objKhachQuen.Type > 1 && objKhachQuen.Rank == 1)
                    {
                        outKieuKhachHang = KieuKhachHangGoiDen.KhachHangVang;
                    }
                    else if (objKhachQuen.Type > 1 && objKhachQuen.Rank == 2)
                    {
                        outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBac;
                    }
                    else
                    {
                        outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
                    }
                    outMaDoiTac = objKhachQuen.MaKH;

                    return(String.Format("[{0}]{1}", objKhachQuen.Name, objKhachQuen.Address));
                }

                //Tim kiem trong DOI TAC (2)
                DoiTac objDoiTac = DoiTac.GetDoiTacByOPhoneNumber(DanhBa.GetSoDienThoaiToiThieu(phoneNumber));

                if (objDoiTac != null && objDoiTac.MaDoiTac.Length > 0)
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangMoiGioi;
                    outMaDoiTac      = objDoiTac.MaDoiTac;
                    return(objDoiTac.Address);
                }

                //Tim kiem trong danh ba dien thoai cua rieng cong ty (1)

                string strDiaChiCuocGoiGanNhat = GetDiaChiCuaCuocGoiGanNhatTrongNgay(DanhBa.GetSoDienThoaiToiThieu(phoneNumber));

                if (strDiaChiCuocGoiGanNhat.Length > 0)
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
                    outMaDoiTac      = "";
                    return(strDiaChiCuocGoiGanNhat);
                }

                //Tim kiem trong danh ba cong ty

                string strDiaChiDanhBaCongTy = DanhBaCongTy.GetDanhBa(DanhBa.GetSoDienThoaiToiThieu(phoneNumber));

                if (strDiaChiDanhBaCongTy.Length > 0)
                {
                    outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;//khach ao
                    outMaDoiTac      = "";
                    return(strDiaChiDanhBaCongTy);
                }

                //Tim kiem trong danh ba dien thoai (1_)
                outKieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
                outMaDoiTac      = "";
                return(DanhBa.GetDanhBa(DanhBa.GetSoDienThoaiToiThieu(phoneNumber)));
            }
            catch
            {
                outKieuKhachHang = KieuKhachHangGoiDen.KhachHangKhongHieu;
                outMaDoiTac      = string.Empty;
                return(string.Empty);
            }
        }