예제 #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();
 }