Пример #1
0
        private void RefreshItems(object sender, EventArgs e)
        {
            var biz = new ConfigurationBiz();

            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
Пример #2
0
        public ConfigurationView(User user)
        {
            InitializeComponent();

            currentUser = user;

            dataGridView.AutoGenerateColumns = false;

            var biz = new ConfigurationBiz();
            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
Пример #3
0
        public ConfigurationView(User user)
        {
            InitializeComponent();

            currentUser = user;

            dataGridView.AutoGenerateColumns = false;

            var biz = new ConfigurationBiz();

            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
Пример #4
0
        private void DeleteItem(object sender, EventArgs e)
        {
            var items = new List <Configuration>();

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

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

                RefreshItems(sender, e);
            }
        }
Пример #5
0
        private void DeleteItem(object sender, EventArgs e)
        {
            var items = new List<Configuration>();

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

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

                RefreshItems(sender, e);
            }
        }
Пример #6
0
        public ConfigurationForm(int id, User user)
        {
            InitializeComponent();

            textKey.Focus();
            itemId = id;

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

            textKey.Text = item.Key;
            textValue.Text = item.Value;
            created = item.Created;
            createdBy = item.CreatedByUserId;
            IsEncryption.Checked = item.Encryption;
            modified = item.Modified;
            modifiedBy = item.ModifiedByUserId;

            InitForm(user);

            this.Text = "Sửa cấu hình hệ thống";
        }
Пример #7
0
        public ConfigurationForm(int id, User user)
        {
            InitializeComponent();

            textKey.Focus();
            itemId = id;

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

            textKey.Text         = item.Key;
            textValue.Text       = item.Value;
            created              = item.Created;
            createdBy            = item.CreatedByUserId;
            IsEncryption.Checked = item.Encryption;
            modified             = item.Modified;
            modifiedBy           = item.ModifiedByUserId;

            InitForm(user);

            this.Text = "Sửa cấu hình hệ thống";
        }
Пример #8
0
        private void SaveItem(object sender, EventArgs e)
        {
            if (CustomValidation())
            {
                var item = new Configuration();
                item.Key = textKey.Text;
                item.Value = textValue.Text;
                item.Encryption = IsEncryption.Checked;
                if (IsEncryption.Checked)
                {
                    item.Value = Utility.EncodePassword(textValue.Text);
                }

                if (itemId > 0)
                {
                    try
                    {
                        item.Id = itemId;
                        item.Created = created;
                        item.CreatedByUserId = createdBy;

                        item.Modified = DateTime.Now;
                        item.ModifiedByUserId = currentUser;

                        var biz = new ConfigurationBiz();

                        biz.UpdateItem(item);
                    }
                    catch (Exception ex)
                    {
                        logger.LogInfoMessage("----Update Configuration ERROR----");
                        logger.LogException(ex);
                    }
                }
                else
                {
                    try
                    {
                        item.Created = DateTime.Now;
                        item.CreatedByUserId = currentUser;

                        item.Modified = DateTime.Now;
                        item.ModifiedByUserId = currentUser;

                        var biz = new ConfigurationBiz();
                        biz.SaveItem(item);
                    }
                    catch(Exception ex)
                    {
                        logger.LogInfoMessage("----Create Configuration ERROR----");
                        logger.LogException(ex);
                    }
                }

                this.Close();
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
Пример #9
0
        private void SaveItem(object sender, EventArgs e)
        {
            if (CustomValidation())
            {
                var item = new Configuration();
                item.Key        = textKey.Text;
                item.Value      = textValue.Text;
                item.Encryption = IsEncryption.Checked;
                if (IsEncryption.Checked)
                {
                    item.Value = Utility.EncodePassword(textValue.Text);
                }

                if (itemId > 0)
                {
                    try
                    {
                        item.Id              = itemId;
                        item.Created         = created;
                        item.CreatedByUserId = createdBy;

                        item.Modified         = DateTime.Now;
                        item.ModifiedByUserId = currentUser;

                        var biz = new ConfigurationBiz();

                        biz.UpdateItem(item);
                    }
                    catch (Exception ex)
                    {
                        logger.LogInfoMessage("----Update Configuration ERROR----");
                        logger.LogException(ex);
                    }
                }
                else
                {
                    try
                    {
                        item.Created         = DateTime.Now;
                        item.CreatedByUserId = currentUser;

                        item.Modified         = DateTime.Now;
                        item.ModifiedByUserId = currentUser;

                        var biz = new ConfigurationBiz();
                        biz.SaveItem(item);
                    }
                    catch (Exception ex)
                    {
                        logger.LogInfoMessage("----Create Configuration ERROR----");
                        logger.LogException(ex);
                    }
                }

                this.Close();
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
Пример #10
0
 private void RefreshItems(object sender, EventArgs e)
 {
     var biz = new ConfigurationBiz();
     dataGridView.DataSource = biz.LoadItems();
     dataGridView.Refresh();
 }