private void btnSetBackGroundImg_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dlg = new OpenFileDialog();

                dlg.Filter           = "JPEG Format Picture (*.jpg) | *.jpg|All files (*.*)| *.*";
                dlg.DefaultExt       = "*.jpg";
                dlg.InitialDirectory = BLLConfig.Instance.GetConfigByCode(eConfigCode.ImagePath);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    if (File.Exists(dlg.FileName))
                    {
                        db = new QMSSystemEntities();
                        Q_Config model = db.Q_Config.FirstOrDefault(x => !x.IsDeleted && x.IsActived && x.Code.Equals(eConfigCode.Background));
                        if (model != null)
                        {
                            model.Value = dlg.FileName;
                            BLLConfig.Instance.UpdateConfigValueFromInterface(model);
                        }
                        Image img = new Bitmap(dlg.FileName);
                        this.frm.BackgroundImage       = img;
                        this.frm.BackgroundImageLayout = ImageLayout.Stretch;
                        this.frm.Refresh();
                    }
                }
                dlg.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi" + ex.Message);
            }
        }
Beispiel #2
0
        private void gridViewConfig_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                int Id = 0;
                int.TryParse(gridViewConfig.GetRowCellValue(gridViewConfig.FocusedRowHandle, "Id").ToString(), out Id);

                if ((Id != 0 || Id == 0) && string.IsNullOrEmpty(gridViewConfig.GetRowCellValue(gridViewConfig.FocusedRowHandle, "Value").ToString()))
                {
                    MessageBox.Show("Vui lòng nhập giá trị.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var obj = new Q_Config();
                    obj.Id        = Id;
                    obj.Code      = gridViewConfig.GetRowCellValue(gridViewConfig.FocusedRowHandle, "Code").ToString();
                    obj.Value     = gridViewConfig.GetRowCellValue(gridViewConfig.FocusedRowHandle, "Value").ToString();
                    obj.IsActived = (bool)gridViewConfig.GetRowCellValue(gridViewConfig.FocusedRowHandle, "IsActived");
                    obj.Note      = gridViewConfig.GetRowCellValue(gridViewConfig.FocusedRowHandle, "Note") != null?gridViewConfig.GetRowCellValue(gridViewConfig.FocusedRowHandle, "Note").ToString() : "";

                    BLLConfig.Instance.Update(connect, obj);
                    GetGridConfig();
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #3
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                numcol = UpDownNumOfColumn.Value.ToString();
                if (numcol != "")
                {
                    db = new QMSSystemEntities();
                    Q_Config model = db.Q_Config.FirstOrDefault(x => !x.IsDeleted && x.IsActived && x.Code.Trim().ToUpper().Equals(eConfigCode.Column));
                    if (model != null)
                    {
                        model.Value = numcol;
                        BLLConfig.Instance.UpdateConfigValueFromInterface(model);
                        //if (MessageBox.Show("Điều chỉnh này chỉ có tác dụng khi bạn khởi động lại chương trình", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                        //    this.Close();

                        for (int i = 0; i < frm.Controls.Count; i++)
                        {
                            if (frm.Controls[i] is Button && frm.Controls[i].Name.StartsWith(eConfigCode.ButtonName))
                            {
                                frm.Controls.RemoveAt(i);
                                i--;
                            }
                        }
                        frm.frmIssueTicketScreen_Load(sender, e);
                    }
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi:" + ex.Message);
            }
        }
Beispiel #4
0
 public int Insert(string connectString, Q_Config obj)
 {
     using (db = new QMSSystemEntities(connectString))
     {
         db.Q_Config.Add(obj);
         db.SaveChanges();
         return(obj.Id);
     }
 }
Beispiel #5
0
 public int Insert(Q_Config obj)
 {
     using (db = new QMSSystemEntities())
     {
         db.Q_Config.Add(obj);
         db.SaveChanges();
         return(obj.Id);
     }
 }
Beispiel #6
0
 public bool Update(string connectString, Q_Config model)
 {
     using (db = new QMSSystemEntities(connectString))
     {
         var obj = db.Q_Config.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id);
         if (obj != null)
         {
             obj.Value     = model.Value;
             obj.IsActived = model.IsActived;
             obj.Note      = model.Note;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Beispiel #7
0
 public bool UpdateConfigValueFromInterface(Q_Config model)
 {
     using (db = new QMSSystemEntities())
     {
         var obj = db.Q_Config.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id);
         if (obj != null)
         {
             //obj.Code = obj.Code;
             obj.Value = model.Value;
             //obj.IsActived = obj.IsActived;
             //obj.Note = obj.Note;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }