Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                if (string.IsNullOrWhiteSpace(txtID.Text))
                {
                    clsMessages.ShowInformation("Vui lòng chọn dòng dữ liệu muốn xóa!");
                    return;
                }
                long lID = Convert.ToInt64(txtID.Text);

                ds = BranchOfficeDAO.BranchOffice_Del(lID);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1)
                {
                    clsMessages.ShowInformation("Xóa thành công!");
                    LoadDataToForm();
                }
                else
                {
                    clsMessages.ShowWarning(ds.Tables[0].Rows[0]["ErrorDesc"].ToString());
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                BranchOfficeDTO objBranch = new BranchOfficeDTO();
                objBranch.ID         = -1;
                objBranch.Name       = txtName.Text;
                objBranch.Phone      = txtPhone.Text;
                objBranch.Fax        = txtFax.Text;
                objBranch.IDLocation = Convert.ToInt64((cboLocation.SelectedItem as clsComboItem).Value);

                ds = BranchOfficeDAO.BranchOffice_Search(objBranch);
                if (ds != null && ds.Tables.Count > 0)
                {
                    dgvBranchOffice.DataSource = ds.Tables[0].Copy();
                }
                else
                {
                    clsMessages.ShowWarning("Không tìm thấy");
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }
Ejemplo n.º 3
0
        public void LoadDataToForm()
        {
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            try
            {
                ds = BranchOfficeDAO.BranchOffice_GetAll();
                if (ds != null && ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0].Copy();
                    dgvBranchOffice.DataSource = dt.Copy();
                    dt.Clear();
                }
                ds.Clear();
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
                dt.Dispose();
            }
        }
Ejemplo n.º 4
0
        private void LoadDataToCombobox()
        {
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            try
            {
                ds = BranchOfficeDAO.LoadDataCombobox().Copy();
                if (ds != null && ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0].Copy();
                    cboBranchOffice.Items.Add(new clsComboItem(-1, ""));
                    foreach (DataRow item in dt.Rows)
                    {
                        clsComboItem itemCbo = new clsComboItem();
                        itemCbo.Value   = item["Value"];
                        itemCbo.Display = item["Display"].ToString();
                        cboBranchOffice.Items.Add(itemCbo);
                    }
                    cboBranchOffice.SelectedIndex = dt.Rows.Count > 0 ? 0 : -1;
                    dt.Clear();
                }
                ds.Clear();
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
                dt.Dispose();
            }
        }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                BranchOfficeDTO obj = new BranchOfficeDTO();
                obj.ID         = -1;
                obj.Name       = txtName.Text;
                obj.Phone      = txtPhone.Text;
                obj.Fax        = txtFax.Text;
                obj.IDLocation = Convert.ToInt64((cboLocation.SelectedItem as clsComboItem).Value);

                ds = BranchOfficeDAO.BranchOffice_InsUpd(obj);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1)
                {
                    clsMessages.ShowInformation("Thêm thành công!");
                    frmParent.LoadDataToForm();
                    this.Close();
                }
                else
                {
                    clsMessages.ShowWarning("Thêm thất bại!");
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }
Ejemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                BranchOfficeDTO obj = new BranchOfficeDTO();
                if (string.IsNullOrWhiteSpace(txtID.Text))
                {
                    clsMessages.ShowInformation("Vui lòng chọn dòng dữ liệu muốn sửa!");
                    return;
                }
                obj.ID         = Convert.ToInt64(txtID.Text);
                obj.Name       = txtName.Text;
                obj.Phone      = txtPhone.Text;
                obj.Fax        = txtFax.Text;
                obj.IDLocation = Convert.ToInt64((cboLocation.SelectedItem as clsComboItem).Value);

                ds = BranchOfficeDAO.BranchOffice_InsUpd(obj);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1)
                {
                    clsMessages.ShowInformation("Cập nhật thành công!");
                    LoadDataToForm();
                }
                else
                {
                    clsMessages.ShowWarning("Cập nhật thất bại!");
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }