Exemple #1
0
        private void InsertData()
        {
            data = new DTO.Setting();

            data.Ten = tbTen.Text;
            data.Value = tbGiaTri.Text;
            data.MoTa = tbMoTa.Text;
            data.IsActive = rbSuDung.Checked;

            if (SettingBus.Insert(data, FormMain.user))
            {
                if (MessageBox.Show(string.Format(Constant.MESSAGE_INSERT_SUCCESS, "Cấu hình " + data.Ten) + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_CONTINUE, Constant.CAPTION_CONFIRMATION, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    this.Dispose();
                }
            }
            else
            {
                if (MessageBox.Show(string.Format(Constant.MESSAGE_INSERT_ERROR_DUPLICATED, tbGiaTri.Text) +
                    Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_EXIT, Constant.CAPTION_ERROR, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    this.Dispose();
                }
            }
        }
Exemple #2
0
        public UcInfo(DTO.Setting data)
        {
            InitializeComponent();

            this.data = data;
            isUpdate = true;
            lbSelect.Text = Constant.DEFAULT_TITLE_EDIT;

            Init();

            tbTen.Text = data.Ten;
            tbGiaTri.Text = data.Value;
            tbMoTa.Text = data.MoTa;

            if (data.IsActive)
            {
                rbSuDung.Checked = true;
            }
            else
            {
                rbTamNgung.Checked = true;
            }

            if (data.Id == 2)
            {
                tbGiaTri.Enabled = false;
            }
        }
Exemple #3
0
        public UcInfo()
        {
            InitializeComponent();

            data = new DTO.Setting();
            isUpdate = false;

            Init();
            RefreshData();
        }
Exemple #4
0
        public static bool Delete(Setting data, User user)
        {
            try
            {
                if (data != null)
                {
                    dbContext.Settings.DeleteOnSubmit(data);
                    dbContext.SubmitChanges();

                    return true;
                }
            }
            catch
            {
                //return false;
            }

            CreateSQlConnection();

            return false;
        }
        private void UpdateSetting()
        {
            DTO.Setting dataSetting = SettingBus.GetById(2);

            string order = string.Empty;

            foreach (DataGridViewRow row in dgvThongTin.Rows)
            {
                order += row.Cells[colIdNguyenLieu.Name].Value.ToString() + Constant.SEPERATE_STRING;
            }

            if (dataSetting == null)
            {
                dataSetting = new DTO.Setting();

                dataSetting.Ten = "Thứ tự NL";
                dataSetting.Value = order;
                dataSetting.MoTa = "Sắp xếp thứ tự NL theo bảng Nhật Ký NL";
                dataSetting.IsActive = true;

                if (SettingBus.Insert(dataSetting, FormMain.user))
                {
                    MessageBox.Show(string.Format(Constant.MESSAGE_UPDATE_SUCCESS, "Thứ tự NL"), Constant.CAPTION_INFORMATION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(Constant.MESSAGE_ERROR, Constant.CAPTION_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (dataSetting.Value != order)
            {
                if (MessageBox.Show("Cập nhật thứ tự NL?", Constant.CAPTION_CONFIRMATION,
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    dataSetting.Value = order;
                    dataSetting.IsActive = true;

                    if (SettingBus.Update(dataSetting, FormMain.user))
                    {
                        MessageBox.Show(string.Format(Constant.MESSAGE_UPDATE_SUCCESS, "Thứ tự NL"), Constant.CAPTION_INFORMATION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(Constant.MESSAGE_ERROR, Constant.CAPTION_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
 partial void DeleteSetting(Setting instance);
 partial void UpdateSetting(Setting instance);
 partial void InsertSetting(Setting instance);
Exemple #9
0
 public static bool Update(Setting data, User user)
 {
     return SettingDao.Update(data, user);
 }
Exemple #10
0
 public static bool Insert(Setting data, User user)
 {
     return SettingDao.Insert(data, user);
 }
Exemple #11
0
 public static bool Delete(Setting data, User user)
 {
     return SettingDao.Delete(data, user);
 }
Exemple #12
0
        public static bool Update(Setting data, User user)
        {
            try
            {
                if (data != null)
                {
                    dbContext.SubmitChanges();
                    return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
Exemple #13
0
        public static bool Insert(Setting data, User user)
        {
            try
            {
                if (GetByTen(data.Ten) != null)
                {
                    return false;
                }

                dbContext.Settings.InsertOnSubmit(data);
                dbContext.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }