public List <DiaDanh> DiaDanh_GetByTop(string Top, string Where, string Order)
        {
            List <DiaDanh> list = new List <DiaDanh>();

            using (SqlCommand dbCmd = new SqlCommand("sp_DiaDanh_getByTop", openConnection()))
            {
                DiaDanh obj = new DiaDanh();
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@Top", Top));
                dbCmd.Parameters.Add(new SqlParameter("@Where", Where));
                dbCmd.Parameters.Add(new SqlParameter("@Order", Order));
                SqlDataReader dr = dbCmd.ExecuteReader();
                dr.Close();
                dr = dbCmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        list.Add(obj.DiaDanhIDataReader(dr));
                    }
                }
                dr.Close();
                obj = null;
            }
            return(list);
        }
        private void lnkXoaDiaDanh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //lay du lieu tu luoi
            DiaDanh objDiaDanh = new DiaDanh();

            if (grvDiaDanh.RowCount > 0)
            {
                DataRow row = grvDiaDanh.GetDataRow(grvDiaDanh.FocusedRowHandle);
                objDiaDanh.DiaDanhID     = int.Parse(row["PK_DiaDanh"].ToString());
                objDiaDanh.TenDiaDanh    = row["TenDiaDanh"].ToString();
                objDiaDanh.DiaChi        = row["DiaChi"].ToString();
                objDiaDanh.DienThoai     = row["DienThoai"].ToString();
                objDiaDanh.GhiChu        = row["MoTa"].ToString();
                objDiaDanh.LoaiDiaDanhID = int.Parse(row["FK_LoaiDiaDanh"].ToString());
            }
            else
            {
                return;
            }
            MessageBox.MessageBoxBA msg = new MessageBox.MessageBoxBA();
            if (msg.Show("Bạn có đồng ý xóa địa danh này ?", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.YesNoCancel, Taxi.MessageBox.MessageBoxIconBA.Question).ToString() == DialogResult.Yes.ToString())
            {
                if (objDiaDanh.Delete())
                {
                    //Load lai grid
                    LoadDSDiaDanh(g_LoaiDiaDanhID);
                    new MessageBox.MessageBoxBA().Show("Xóa địa danh thành công");
                }
            }
        }
        public bool DiaDanh_Update(DiaDanh data)
        {
            bool check = false;

            try
            {
                using (SqlCommand dbCmd = new SqlCommand("sp_DiaDanh_Update", openConnection()))
                {
                    dbCmd.CommandType = CommandType.StoredProcedure;
                    dbCmd.Parameters.Add(new SqlParameter("@ID", data.ID));
                    dbCmd.Parameters.Add(new SqlParameter("@TenDiaDanh", data.TenDiaDanh));
                    dbCmd.Parameters.Add(new SqlParameter("@MoTa", data.MoTa));
                    int r = dbCmd.ExecuteNonQuery();
                    if (r > 0)
                    {
                        check = true;
                    }
                }
                //Clear cache
                System.Web.HttpContext.Current.Cache.Remove("DiaDanh");
            }
            catch
            {
            }
            return(check);
        }
Beispiel #4
0
        private void lnkXoaDiaDanh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //lay du lieu tu luoi
            gridDiaDanh.SelectionMode = Janus.Windows.GridEX.SelectionMode.SingleSelection;
            DiaDanh objDiaDanh = new DiaDanh();

            if (gridDiaDanh.SelectedItems.Count > 0)
            {
                GridEXRow row = ((GridEXSelectedItem)gridDiaDanh.SelectedItems[0]).GetRow();
                objDiaDanh.DiaDanhID     = int.Parse(row.Cells["PK_DiaDanh"].Value.ToString());
                objDiaDanh.TenDiaDanh    = row.Cells["TenDiaDanh"].Value.ToString();
                objDiaDanh.DiaChi        = row.Cells["DiaChi"].Value.ToString();
                objDiaDanh.DienThoai     = row.Cells["DienThoai"].Value.ToString();
                objDiaDanh.GhiChu        = row.Cells["MoTa"].Value.ToString();
                objDiaDanh.LoaiDiaDanhID = int.Parse(row.Cells["FK_LoaiDiaDanh"].Value.ToString());
            }
            else
            {
                return;
            }
            MessageBox.MessageBox msg = new MessageBox.MessageBox();
            if (msg.Show("Bạn có đồng ý xóa địa danh này ?", "Thông báo", Taxi.MessageBox.MessageBoxButtons.YesNoCancel, Taxi.MessageBox.MessageBoxIcon.Question).ToString() == DialogResult.Yes.ToString())
            {
                if (objDiaDanh.Delete())
                {
                    //Load lai grid
                    LoadDSDiaDanh(g_LoaiDiaDanhID);
                    new MessageBox.MessageBox().Show("Xóa địa danh thành công");
                }
            }
        }
        private void lnkThemDiaDanh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            frmDiaDanh frm = new frmDiaDanh();

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                DiaDanh objDiaDanh = new DiaDanh();
                objDiaDanh = frm.GetDiaDanh();
                if (objDiaDanh.TenDiaDanh.Length <= 0)
                {
                    return;
                }

                if (objDiaDanh.DiaChi.Length <= 0)
                {
                    return;
                }


                if (!objDiaDanh.Insert())
                {
                    new MessageBox.MessageBoxBA().Show("Lỗi thêm mới địa danh");
                    return;
                }
                else
                {
                    //Load lai grid
                    LoadDSDiaDanh(g_LoaiDiaDanhID);
                    new MessageBox.MessageBoxBA().Show("Thêm mới địa danh thành công");
                }
            }
        }
        /// <summary>
        /// hàm thực hiện lấy dữ liệu autocomplete
        /// </summary>
        private void LoadDuLieuForAutoComplete()
        {
            if (g_ListDataAutoComplete == null)
            {
                g_ListDataAutoComplete = new AutoCompleteEntryCollection();
            }

            string address    = "";
            string streetAbbr = "";
            float  kd         = 0;
            float  vd         = 0;

            using (DataTable dt = new DiaDanh().GetRoadData_Autocomplete())
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    int i = 1;
                    foreach (DataRow row in dt.Rows)
                    {
                        address    = row["Street"].ToString();
                        streetAbbr = row["StreetAbbr"].ToString();
                        kd         = float.Parse(row["KinhDo"].ToString());
                        vd         = float.Parse(row["ViDo"].ToString());

                        g_ListDataAutoComplete.Add(new AutoCompleteEntry(address, kd, vd, streetAbbr));
                        i++;
                    }
                }
            }
        }
Beispiel #7
0
 private void SetDiaDanh(DiaDanh diadanh)
 {
     if (diadanh != null)
     {
         editName.Text                = mDiaDanh.TenDiaDanh;
         editAddress.Text             = mDiaDanh.DiaChi;
         editPhone.Text               = mDiaDanh.DienThoai;
         editMoTa.Text                = mDiaDanh.GhiChu;
         cboLoaiDiaDanh.SelectedValue = (int)mDiaDanh.LoaiDiaDanhID;
     }
 }
        private void lnkSuaDiaDanh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //lay du lieu tu luoi
            gridDiaDanh.SelectionMode = Janus.Windows.GridEX.SelectionMode.SingleSelection;
            DiaDanh objDiaDanh = new DiaDanh();

            if (gridDiaDanh.SelectedItems.Count > 0)
            {
                GridEXRow row = ((GridEXSelectedItem)gridDiaDanh.SelectedItems[0]).GetRow();
                objDiaDanh.DiaDanhID     = int.Parse(row.Cells["PK_DiaDanh"].Value.ToString());
                objDiaDanh.TenDiaDanh    = row.Cells["TenDiaDanh"].Value.ToString();
                objDiaDanh.DiaChi        = row.Cells["DiaChi"].Value.ToString();
                objDiaDanh.DienThoai     = row.Cells["DienThoai"].Value.ToString();
                objDiaDanh.GhiChu        = row.Cells["MoTa"].Value.ToString();
                objDiaDanh.LoaiDiaDanhID = int.Parse(row.Cells["FK_LoaiDiaDanh"].Value.ToString());
            }
            else
            {
                return;
            }

            frmDiaDanh frm = new frmDiaDanh(objDiaDanh, false);

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                objDiaDanh = frm.GetDiaDanh();
                if (objDiaDanh.TenDiaDanh.Length <= 0)
                {
                    return;
                }

                if (objDiaDanh.DiaChi.Length <= 0)
                {
                    return;
                }


                if (!objDiaDanh.Update())
                {
                    new MessageBox.MessageBoxBA().Show("Lỗi cập nhật địa danh");
                    return;
                }
                else
                {
                    //Load lai grid
                    LoadDSDiaDanh(g_LoaiDiaDanhID);
                    new MessageBox.MessageBoxBA().Show("Cập nhật địa danh thành công");
                }
            }
        }
Beispiel #9
0
        /// <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 frmDiaDanh(DiaDanh DiaDanh, bool boolAdd)
        {
            InitializeComponent();
            mIsAdd = boolAdd;
            if (boolAdd)
            {
                this.Text = "Thêm mới địa danh";
            }
            else
            {
                this.Text = "Sửa đổi thông tin địa danh";
            }

            mDiaDanh = DiaDanh;
        }
Beispiel #10
0
        public DiaDanh GetDiaDanh()
        {
            if (mDiaDanh == null)
            {
                mDiaDanh = new DiaDanh();
            }

            mDiaDanh.TenDiaDanh    = StringTools.TrimSpace(editName.Text);
            mDiaDanh.DiaChi        = StringTools.TrimSpace(editAddress.Text);
            mDiaDanh.DienThoai     = StringTools.TrimSpace(editPhone.Text);
            mDiaDanh.GhiChu        = StringTools.TrimSpace(editMoTa.Text);
            mDiaDanh.LoaiDiaDanhID = int.Parse(cboLoaiDiaDanh.SelectedValue.ToString());

            return(mDiaDanh);
        }
        /// <summary>
        /// tim kiếm thông tin địa danh
        /// </summary>
        private void Search()
        {
            string strSearch = StringTools.TrimSpace(txtTimKiem.Text);

            if (strSearch.Length > 0)
            {
                if (rdoDiaChi.Checked)
                {
                    grcDiaDanh.DataSource = DiaDanh.GetDSDiaDanh_ByDiaChi(strSearch);
                }
                else
                {
                    grcDiaDanh.DataSource = DiaDanh.GetDSDiaDanh_ByTenDiaDanh(strSearch);
                }
            }
            else
            {
                LoadDSDiaDanh();
            }
        }
Beispiel #12
0
        /// <summary>
        /// tim kiếm thông tin địa danh
        /// </summary>
        private void Search()
        {
            string strSearch = StringTools.TrimSpace(txtTimKiem.Text);

            if (strSearch.Length > 0)
            {
                gridDiaDanh.DataMember = "ListOfDiaDanh";
                if (rdoDiaChi.Checked)
                {
                    gridDiaDanh.SetDataBinding(DiaDanh.GetDSDiaDanh_ByDiaChi(strSearch), "ListOfDoiTac");
                }
                else
                {
                    gridDiaDanh.SetDataBinding(DiaDanh.GetDSDiaDanh_ByTenDiaDanh(strSearch), "ListOfDoiTac");
                }
            }
            else
            {
                LoadDSDiaDanh();
            }
        }
 public void LoadDSDiaDanh(int LoaiDiaDanhID)
 {
     grcDiaDanh.DataSource = DiaDanh.GetDSDiaDanh_ByLoaiDiaDanh(LoaiDiaDanhID);
 }
Beispiel #14
0
 public bool DiaDanh_Update(DiaDanh data)
 {
     return(obj.DiaDanh_Update(data));
 }
Beispiel #15
0
 public bool DiaDanh_Insert(DiaDanh data)
 {
     return(obj.DiaDanh_Insert(data));
 }
Beispiel #16
0
 public void LoadDSDiaDanh()
 {
     gridDiaDanh.DataMember = "ListOfDiaDanh";
     gridDiaDanh.SetDataBinding(DiaDanh.GetDSDiaDanh(), "ListOfDoiTac");
 }
Beispiel #17
0
 public void LoadDSDiaDanh(int LoaiDiaDanhID)
 {
     gridDiaDanh.DataMember = "ListOfDiaDanh";
     gridDiaDanh.SetDataBinding(DiaDanh.GetDSDiaDanh_ByLoaiDiaDanh(LoaiDiaDanhID), "ListOfDoiTac");
 }
 public void LoadDSDiaDanh()
 {
     grcDiaDanh.DataSource = DiaDanh.GetDSDiaDanh();
 }