Beispiel #1
0
        private void RefreshItems(object sender, EventArgs e)
        {
            var biz = new CityBiz();

            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
Beispiel #2
0
        private bool CustomValidation()
        {
            bool hasError = true;

            errorProvider.Clear();

            if (string.IsNullOrEmpty(textName.Text))
            {
                errorProvider.SetError(textName, Constants.Messages.RequireMessage);
                hasError = false;

                textName.Focus();
            }
            else
            {
                var biz    = new CityBiz();
                var result = biz.SearchByName(textName.Text.Trim());

                if (result)
                {
                    errorProvider.SetError(textName, Constants.Messages.CityExist);
                    hasError = false;

                    textName.Focus();
                }
            }

            return(hasError);
        }
Beispiel #3
0
        private void LoadCities()
        {
            var biz = new CityBiz();

            drlCity.Items.Clear();
            drlCity.DataSource = biz.GetAll();
        }
Beispiel #4
0
        private bool CustomValidation()
        {
            bool hasError = true;
            errorProvider.Clear();

            if (string.IsNullOrEmpty(textName.Text))
            {
                errorProvider.SetError(textName, Constants.Messages.RequireMessage);
                hasError = false;

                textName.Focus();
            }
            else
            {
                var biz = new CityBiz();
                var result = biz.SearchByName(textName.Text.Trim());

                if(result)
                {
                    errorProvider.SetError(textName, Constants.Messages.CityExist);
                    hasError = false;

                    textName.Focus();
                }
            }

            return hasError;
        }
Beispiel #5
0
        public CityView(User user)
        {
            InitializeComponent();

            currentUser = user;

            dataGridView.AutoGenerateColumns = false;

            var biz = new CityBiz();
            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
Beispiel #6
0
        public CityView(User user)
        {
            InitializeComponent();

            currentUser = user;

            dataGridView.AutoGenerateColumns = false;

            var biz = new CityBiz();

            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
Beispiel #7
0
        protected void ddlDivision_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(ddlDivision.SelectedValue))
            {
                ddlCity.DataSource = CityBiz.GetCity(Convert.ToInt32(ddlDivision.SelectedValue));

                ddlCity.DataBind();
                ddlCity.SelectedIndex = 1;
            }
            else
            {
                ddlCity.Items.Clear();
                ddlCity.Items.Insert(0, "--Select Option--");
            }
        }
Beispiel #8
0
        public CityForm(int id, User user)
        {
            InitializeComponent();

            textName.Focus();
            itemId = id;

            var biz  = new CityBiz();
            var item = biz.LoadItem(id);

            textName.Text = item.Name;

            InitForm(user);

            this.Text = "Sửa thông tin thành phố";
        }
Beispiel #9
0
        public CityForm(int id, User user)
        {
            InitializeComponent();

            textName.Focus();
            itemId = id;

            var biz = new CityBiz();
            var item = biz.LoadItem(id);

            textName.Text = item.Name;

            InitForm(user);

            this.Text = "Sửa thông tin thành phố";
        }
Beispiel #10
0
        private void SaveItem(object sender, EventArgs e)
        {
            if (CustomValidation())
            {
                var item = new City();
                item.Name = textName.Text;

                if (itemId > 0)
                {
                    try
                    {
                        item.Id = itemId;

                        var biz = new CityBiz();

                        biz.UpdateItem(item);
                    }
                    catch (Exception ex)
                    {
                        logger.LogInfoMessage("----Update City ERROR----");
                        logger.LogException(ex);
                    }
                }
                else
                {
                    try
                    {
                        var biz = new CityBiz();
                        biz.SaveItem(item);
                    }
                    catch (Exception ex)
                    {
                        logger.LogInfoMessage("----Create City ERROR----");
                        logger.LogException(ex);
                    }
                }

                this.Close();
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
Beispiel #11
0
        private void DeleteItem(object sender, EventArgs e)
        {
            var items = new List <City>();

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[0].Value == "1")
                {
                    items.Add(row.DataBoundItem as City);
                }
            }

            if (items.Count > 0)
            {
                var biz = new CityBiz();
                biz.RemoveItem(items);

                RefreshItems(sender, e);
            }
        }
Beispiel #12
0
        private void DeleteItem(object sender, EventArgs e)
        {
            var items = new List<City>();

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[0].Value == "1")
                {
                    items.Add(row.DataBoundItem as City);
                }
            }

            if (items.Count > 0)
            {
                var biz = new CityBiz();
                biz.RemoveItem(items);

                RefreshItems(sender, e);
            }
        }
Beispiel #13
0
 private void LoadCities()
 {
     var biz = new CityBiz();
     drlCity.Items.Clear();
     drlCity.DataSource = biz.GetAll();
 }
Beispiel #14
0
        private void SaveItem(object sender, EventArgs e)
        {
            if (CustomValidation())
            {
                var item = new City();
                item.Name = textName.Text;

                if (itemId > 0)
                {
                    try
                    {
                        item.Id = itemId;

                        var biz = new CityBiz();

                        biz.UpdateItem(item);
                    }
                    catch (Exception ex)
                    {
                        logger.LogInfoMessage("----Update City ERROR----");
                        logger.LogException(ex);
                    }
                }
                else
                {
                    try
                    {
                        var biz = new CityBiz();
                        biz.SaveItem(item);
                    }
                    catch(Exception ex)
                    {
                        logger.LogInfoMessage("----Create City ERROR----");
                        logger.LogException(ex);
                    }
                }

                this.Close();
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
Beispiel #15
0
 private void RefreshItems(object sender, EventArgs e)
 {
     var biz = new CityBiz();
     dataGridView.DataSource = biz.LoadItems();
     dataGridView.Refresh();
 }