Ejemplo n.º 1
0
 public void InsertUpdateFormState(Model.Common.FormState model, int type)
 {
     Model.Common.ArchiveCommonDataClassesDataContext db = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
     if (type == 1)
     {
         db.FormStates.InsertOnSubmit(model);
     }
     else
     {
         var model2 = db.FormStates.Where(a => a.MachineName == model.MachineName && a.FormName == model.FormName).FirstOrDefault();
         model2.Width = model.Width;
     }
     db.SubmitChanges();
 }
Ejemplo n.º 2
0
        //private void Form_Shown(object sender, EventArgs e)
        //{
        //    System.Windows.Forms.Form form = sender as System.Windows.Forms.Form;
        //    System.Drawing.Size? size = (form.Tag as System.Drawing.Size?);
        //    form.MinimumSize = size == null ? System.Drawing.Size.Empty : size.Value;
        //    form.Shown -= Form_Shown;
        //}

        public override void SaveFormState(System.Windows.Forms.Form form)
        {
            Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
            Model.Common.FormState state = Model.Common.FormState.GetNewInstance(Environment.MachineName, form.Name, (int)form.WindowState, form.Width, form.Height, form.Location.X, form.Location.Y);
            var query = dc.FormStates.Where(t => t.MachineName == Environment.MachineName && t.FormName == form.Name);

            if (query.Count() == 1)
            {
                Model.Common.FormState originalState = query.Single();
                Model.Common.FormState.Copy(originalState, state);
                dc.SubmitChanges();
            }
            else
            {
                Model.Common.FormState.Insert(dc, state);
                dc.SubmitChanges();
            }
        }
Ejemplo n.º 3
0
        public override void LoadFormState(System.Windows.Forms.Form form)
        {
            Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
            var query = dc.FormStates.Where(t => t.MachineName == Environment.MachineName && t.FormName == form.Name);

            if (query.Count() == 1)
            {
                Model.Common.FormState state = query.Single();
                switch ((System.Windows.Forms.FormWindowState)state.WindowState)
                {
                case System.Windows.Forms.FormWindowState.Maximized:
                    form.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                    break;

                case System.Windows.Forms.FormWindowState.Minimized:
                    break;

                case System.Windows.Forms.FormWindowState.Normal:
                    form.WindowState = System.Windows.Forms.FormWindowState.Normal;
                    //form.Tag = form.MinimumSize;
                    //form.MinimumSize = new System.Drawing.Size(state.Width, state.Height);
                    form.Width  = state.Width;
                    form.Height = state.Height;
                    //form.Shown += Form_Shown;
                    if (state.X == 0 && state.Y == 0)
                    {
                        form.Location = new System.Drawing.Point(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2 - form.Width / 2, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / 2 - form.Height / 2);
                    }
                    else
                    {
                        form.Left = state.X;
                        form.Top  = state.Y;
                    }
                    break;
                }
            }
            else
            {
                form.Location = new System.Drawing.Point(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2 - form.Width / 2, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / 2 - form.Height / 2);
            }
        }
Ejemplo n.º 4
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
            var query = dc.FormStates.Where(t => t.MachineName == Environment.MachineName && t.FormName == "Scanner");

            if (query.Count() == 1)
            {
                query.FirstOrDefault().X      = comboBoxImageType.SelectedIndex;
                query.FirstOrDefault().Y      = comboBoxSource.SelectedIndex;
                query.FirstOrDefault().Width  = cmResolation.SelectedIndex;
                query.FirstOrDefault().Height = cmResolation.SelectedIndex;
                dc.SubmitChanges();
            }
            else
            {
                Model.Common.FormState state = Model.Common.FormState.GetNewInstance(Environment.MachineName, "Scanner", 1, comboBoxImageType.SelectedIndex, comboBoxSource.SelectedIndex, cmResolation.SelectedIndex, cmResolation.SelectedIndex);
                Model.Common.FormState.Insert(dc, state);
                dc.SubmitChanges();
            }

            PersianMessageBox.Show("اطلاعات با موفقیت ذخیره شد.");
        }
Ejemplo n.º 5
0
        //مخفی کردن ستون
        private void DossierDocumentsManage2_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(_ColumnName);
            Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
            var query = dc.FormStates.Where(t => t.MachineName == Environment.MachineName && t.FormName == _ColumnName);

            if (query.Count() == 1)
            {
                if (query.FirstOrDefault().WindowState == 20)
                {
                    query.FirstOrDefault().WindowState = 9;
                    dc.SubmitChanges();
                }
            }
            else
            {
                //برای مخفی کردن باید Windowsstate=9
                //برای مخفی نکردن باید Windowsstate=20
                Model.Common.FormState state = Model.Common.FormState.GetNewInstance(Environment.MachineName, _ColumnName, 9, 0, 0, 0, 0);
                Model.Common.FormState.Insert(dc, state);
                dc.SubmitChanges();
            }
        }
Ejemplo n.º 6
0
        public void CheckWhdth(Njit.Program.Telerik.Controls.RadGridViewExtended radGridView, int i, bool FirstLoadDatagrid)
        {
            if (GetQuery)
            {
                Model.Common.ArchiveCommonDataClassesDataContext db = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
                LstFormState = db.FormStates.Where(a => a.MachineName == Environment.MachineName).ToList();
                if (LstFormState == null)
                {
                    var model = new Model.Common.FormState
                    {
                        FormName    = radGridView.Columns[0].Name,
                        Height      = 0,
                        Width       = radGridView.Columns[0].Width,
                        X           = 1,
                        Y           = 2,
                        MachineName = Environment.MachineName,
                        WindowState = 20
                    };
                    InsertUpdateFormState(model, 1);
                }
                GetQuery = false;
            }
            string _FormName = "";

            _FormName = radGridView.Columns[i].Name;

            var Data = LstFormState.Where(a => a.FormName == _FormName).FirstOrDefault();

            if (Data == null)
            {
                var model = new Model.Common.FormState
                {
                    FormName    = radGridView.Columns[i].Name,
                    Height      = 0,
                    Width       = radGridView.Columns[i].Width,
                    X           = 1,
                    Y           = 2,
                    MachineName = Environment.MachineName,
                    WindowState = 20
                };
                InsertUpdateFormState(model, 1);
            }
            else if (Data.FormName == _FormName)
            {
                if (FirstLoadDatagrid)//زمانی که صفحه لود میشود عرض را از دیتابیس میگیرد
                {
                    radGridView.Columns[i].Width = Data.Width;
                }
                else//اگر بعد از لود صفحه تغییر در عرض رخ داد در دیتابیس تغییر میکند
                {
                    var model = new Model.Common.FormState
                    {
                        FormName    = radGridView.Columns[i].Name,
                        Height      = 0,
                        Width       = radGridView.Columns[i].Width,
                        X           = 1,
                        Y           = 2,
                        MachineName = Environment.MachineName,
                        WindowState = 20
                    };
                    InsertUpdateFormState(model, 2);
                }
            }
        }