Exemplo n.º 1
0
 protected override void OnSaveComplete()
 {
     base.OnSaveComplete();
     if (this.PersonnelNumber != null)
     {
         ProgramEvents.OnDocumentsChanged();
     }
 }
Exemplo n.º 2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!(this.ActiveControl == btnOK || this.ActiveControl == nameTextBox))
     {
         Njit.Common.SendKeys.SendKeyDown(Keys.Tab);
         return;
     }
     try
     {
         ValidateContents();
     }
     catch (Njit.Common.ValidateException ex)
     {
         if (ex.Control != null)
         {
             ex.Control.TextChanged -= ControlTextChanged;
             ex.Control.Leave       -= ControlLeave;
         }
         PersianMessageBox.Show(ex.Message);
         if (ex.Control != null)
         {
             ex.Control.Focus();
             ex.Control.TextChanged += ControlTextChanged;
             ex.Control.Leave       += ControlLeave;
             errorProvider.SetError(ex.Control, ex.Message);
         }
         return;
     }
     if (!EditMode)
     {
         try
         {
             Controller.Archive.PersonController.AddPerson(nameTextBox.Text);
         }
         catch (Exception ex)
         {
             PersianMessageBox.Show(this, "خطا در ثبت اطلاعات" + ex.Message);
             return;
         }
     }
     else
     {
         try
         {
             Controller.Archive.PersonController.UpdatePerson(this.OriginalPerson.ID, nameTextBox.Text);
         }
         catch (Exception ex)
         {
             PersianMessageBox.Show(this, "خطا در ثبت اطلاعات" + ex.Message);
             return;
         }
     }
     ProgramEvents.OnPersonsChanged();
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.Close();
 }
Exemplo n.º 3
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!(btnOK.Focused || timeTimeControl.Focused))
     {
         Njit.Common.SendKeys.SendKeyDown(Keys.Tab);
         return;
     }
     try
     {
         ValidateContent();
     }
     catch (Njit.Common.ValidateException ex)
     {
         if (ex.Control != null)
         {
             ex.Control.TextChanged -= ControlTextChanged;
             ex.Control.Leave       -= ControlLeave;
         }
         PersianMessageBox.Show(ex.Message);
         if (ex.Control != null)
         {
             ex.Control.Focus();
             ex.Control.TextChanged += ControlTextChanged;
             ex.Control.Leave       += ControlLeave;
             errorProvider.SetError(ex.Control, ex.Message);
         }
         return;
     }
     try
     {
         if (dateDateControl.DateIsFree)
         {
             Controller.Archive.LendingController.UnReturnLending(this.Lending.ID);
         }
         else
         {
             Controller.Archive.LendingController.ReturnLending(this.Lending.ID, dateDateControl.Text, timeTimeControl.Text);
         }
     }
     catch (Exception ex)
     {
         PersianMessageBox.Show(this, "خطا در ثبت اطلاعات" + "\r\n\r\n" + ex.Message);
         return;
     }
     ProgramEvents.OnLendingsChanged();
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.Close();
 }
Exemplo n.º 4
0
 void DeleteForm_DeleteAll(object sender, Njit.Program.Forms.DeleteForm.DeleteAllEventArgs e)
 {
     foreach (ListViewItem item in e.Items)
     {
         Model.Archive.Person person = (Model.Archive.Person)item.Tag;
         try
         {
             Controller.Archive.PersonController.Delete(person.ID);
         }
         catch (Exception ex)
         {
             e.ErrorList.Add(ex.Message);
         }
     }
     ProgramEvents.OnPersonsChanged();
 }
Exemplo n.º 5
0
        public void AddLog(Model.Common.ArchiveCommonDataClassesDataContext dc, UserOparatesPlaceNames operatingPlaceCode, UserOparatesNames operatingCode, string code, string description)
        {
            int userCode = Setting.User.ThisProgram.GetCurrentUser <Model.Common.User>().Code;

            var des = GetUserLogCryptoService(userCode);

            string code_encrypted = ((code == null) ? null : des.EncryptToBase64(code));
            string operatingPlaceCode_encrypted = ((operatingPlaceCode == UserOparatesPlaceNames.None) ? null : des.EncryptToBase64(((short)operatingPlaceCode).ToString()));
            string operatingCode_encrypted      = des.EncryptToBase64(((short)operatingCode).ToString());
            string sysdate_encrypted            = des.EncryptToBase64(DataAccess.CommonDataAccess.GetNewInstance().Connection.GetServerPersianDate());
            string systime_encrypted            = des.EncryptToBase64(DataAccess.CommonDataAccess.GetNewInstance().Connection.GetServerTime());
            string description_encrypted        = ((description == null) ? null : des.EncryptToBase64(description));

            Model.Common.UserLog userlog = Model.Common.UserLog.GetNewInstance(userCode, operatingPlaceCode_encrypted, operatingCode_encrypted, code_encrypted, description_encrypted, sysdate_encrypted, systime_encrypted, Setting.Archive.ThisProgram.SelectedArchiveTree == null ? null : (int?)Setting.Archive.ThisProgram.SelectedArchiveTree.Archive.ID, Setting.Program.GetMacAddress().ToString());
            Model.Common.UserLog.Insert(dc, userlog);
            dc.SubmitChanges();

            ProgramEvents.OnUserLogsChanged();
        }
Exemplo n.º 6
0
 public override bool SaveSettings()
 {
     if (!base.SaveSettings())
     {
         return(false);
     }
     try
     {
         string documentsPathOrDatabaseName = Setting.Archive.ThisProgram.LoadedArchiveSettings.UseDatabase ? Setting.Archive.ThisProgram.LoadedArchiveSettings.DocumentsPathOrDatabaseName : txtDocumentsPath.Text;
         Setting.Archive.ThisProgram.LoadedArchiveSettings = Model.Archive.ArchiveSetting.GetNewInstance(pictureSelectBoxBackground.DataStream == null || (pictureSelectBoxBackground.DataStream != null && pictureSelectBoxBackground.DataStream.Length == 0) ? null : new System.Data.Linq.Binary(pictureSelectBoxBackground.DataStream.ToArray()), txtBackupPath.Text, Setting.Archive.ThisProgram.LoadedArchiveSettings.AutoBackup, txtOrganName.Text, pictureSelectBoxLogo.DataStream == null || (pictureSelectBoxLogo.DataStream != null && pictureSelectBoxLogo.DataStream.Length == 0) ? null : new System.Data.Linq.Binary(pictureSelectBoxLogo.DataStream.ToArray()), documentsPathOrDatabaseName, txtPersonnelNumber_Label.Text, txtPersonnelNumber_MinLength.IntValue.Value, txtPersonnelNumber_MaxLength.IntValue.Value, checkBoxShowContactTab.Checked, Setting.Archive.ThisProgram.LoadedArchiveSettings.UseDatabase, Setting.Archive.ThisProgram.LoadedArchiveSettings.DatabasePath, Setting.Archive.ThisProgram.LoadedArchiveSettings.DefaultFilesSavePath, (int)cmbDocumentsFormat.SelectedValue, (int)cmbCompressionType.SelectedValue, txtMaxDocSize.IntValue.Value);
         Setting.Archive.ThisProgram.SaveAndReloadArchiveSettings();
         Setting.Archive.ThisProgram.LoadedCommonSettings = Model.Common.ProgramSetting.GetNewInstance(chkShowBackupFormOnExit.Checked, null, null);
         Setting.Archive.ThisProgram.SaveAndReloadCommonSettings();
     }
     catch (Exception ex)
     {
         PersianMessageBox.Show(this, "خطا در ذخیره تنظیمات" + Environment.NewLine + Environment.NewLine + ex.Message);
         return(false);
     }
     ProgramEvents.OnProgramSettingsChanged();
     return(true);
 }
Exemplo n.º 7
0
        void StopPlayingMap(ProgramEvents.StopPlayingMap e)
        {
            int prevSilver = GetMaxSilverYield(e.MapFileName);
            GameInstances.Add(e);

            if(e.GameState == Client.Game.GameState.Won && CurrentMap != null)
            {
                if (!Program.Settings.DeveloperMainMenu)
                {
                    if (e.SilverYield > prevSilver)
                        SilverCoins += e.SilverYield - prevSilver;

                    bool d;
                    if (!CompletedMaps.TryGetValue(CurrentMap.MapName, out d)) d = false;
                    CompletedMaps[CurrentMap.MapName] = true;

                    int ge = 0;
                    if (!d)
                    {
                        ge = CurrentMap.Yield;
                        GoldCoins += CurrentMap.Yield;
                    }

                    Save();
                    if(!d)
                        Program.Instance.SignalEvent(new ProgramEvents.CompletedMap
                        {
                            MapName = CurrentMap.MapName,
                            GoldEarned = ge
                        });
                }
            }
            CurrentMap = null;
            currentMapFileName = null;
        }
Exemplo n.º 8
0
 void StartPlayingMap(ProgramEvents.StartPlayingMap e)
 {
     currentMapFileName = e.MapName;
     CurrentMap = Campaign.Campaign1().GetMapByFilename(e.MapName);
     Save();
 }
Exemplo n.º 9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!(btnOK.Focused || nameTextBox.Focused))
            {
                Njit.Common.SendKeys.SendKeyDown(Keys.Tab);
                return;
            }
            try
            {
                ValidateContent();
            }
            catch (Njit.Common.ValidateException ex)
            {
                ex.Control.TextChanged -= ControlTextChanged;
                PersianMessageBox.Show(ex.Message);
                ex.Control.Focus();
                ex.Control.TextChanged += ControlTextChanged;
                errorProvider.SetError(ex.Control, ex.Message);
                return;
            }
            Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);

            Model.Common.UserRole newInstance = Model.Common.UserRole.GetNewInstance(nameTextBox.Text, false);
            dc.Connection.Open();
            dc.Transaction = dc.Connection.BeginTransaction();
            try
            {
                if (!EditMode)
                {
                    Model.Common.UserRole.Insert(dc, newInstance);
                    dc.SubmitChanges();
                    try
                    {
                        Setting.User.ThisProgram.AddLog(dc, Setting.User.UserOparatesPlaceNames.کاربران, Setting.User.UserOparatesNames.ثبت, null, "ثبت گروه کاربران '" + newInstance.Name + "'");
                    }
                    catch
                    {
                        throw new Exception("خطا در ذخیره عملکرد کاربر جاری");
                    }
                }
                else
                {
                    Model.Common.UserRole originalInstance = dc.UserRoles.Where(t => t.ID == this.OriginalUserRole.ID).Single();
                    string originalName = originalInstance.Name;
                    Model.Common.UserRole.Copy(originalInstance, newInstance);
                    dc.SubmitChanges();
                    try
                    {
                        Setting.User.ThisProgram.AddLog(dc, Setting.User.UserOparatesPlaceNames.کاربران, Setting.User.UserOparatesNames.ویرایش, null, "ویرایش گروه کاربران '" + originalName + "'");
                    }
                    catch
                    {
                        throw new Exception("خطا در ذخیره عملکرد کاربر جاری");
                    }
                }
            }
            catch (Exception ex)
            {
                dc.Transaction.Rollback();
                dc.Connection.Close();
                PersianMessageBox.Show(this, "خطا در ثبت اطلاعات" + Environment.NewLine + Environment.NewLine + ex.Message);
                return;
            }
            dc.Transaction.Commit();
            dc.Connection.Close();

            ProgramEvents.OnUserRolesChanged();

            if (EditMode)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            else
            {
                PersianMessageBox.Show(this, "اطلاعات ثبت شد");
                Model.Common.UserRole.Copy(this.UserRole, Model.Common.UserRole.GetNewInstance("", false));
                nameTextBox.Focus();
            }
        }
Exemplo n.º 10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!(this.ActiveControl == btnOK || this.ActiveControl == durationHourTextBoxExtended))
            {
                Njit.Common.SendKeys.SendKeyDown(Keys.Tab);
                return;
            }
            try
            {
                ValidateContent();
            }
            catch (Njit.Common.ValidateException ex)
            {
                if (ex.Control != null)
                {
                    ex.Control.TextChanged -= ControlTextChanged;
                    ex.Control.Leave       -= ControlLeave;
                }
                PersianMessageBox.Show(ex.Message);
                if (ex.Control != null)
                {
                    ex.Control.Focus();
                    ex.Control.TextChanged += ControlTextChanged;
                    ex.Control.Leave       += ControlLeave;
                    errorProvider.SetError(ex.Control, ex.Message);
                }
                return;
            }
            Model.Archive.Dossier dossier = Controller.Archive.DossierController.Select(this.PersonnelNumber);
            if (!isAccessPermission(dossier))
            {
                PersianMessageBox.Show(this, string.Format("مجوز دسترسی به پرونده های با سطح دسترسی '{0}' برای شما صادر نشده است", dossier.DossierType.Title));
                this.Close();
                return;
            }
            int lendingID = 0;

            try
            {
                Model.Archive.Person person = Controller.Archive.PersonController.SearchPersonByName(cmPerson.Text);
                if (person == null)
                {
                    person = Controller.Archive.PersonController.AddPerson(cmPerson.Text);
                }
                if (person != null)
                {
                    if (!EditMode)
                    {
                        lendingID = Controller.Archive.LendingController.AddLending(Model.Archive.Lending.GetNewInstance(this.PersonnelNumber, person.ID, intentionComboBoxExtended.Text, dateDateControl.Text, timeTimeControl.Text, durationDayTextBoxExtended.IntValue.Value, durationHourTextBoxExtended.IntValue.Value, null, null, null, null, Setting.User.ThisProgram.GetCurrentUser <Model.Common.User>().Code.ToString()));
                    }
                    else
                    {
                        lendingID = Controller.Archive.LendingController.UpdateLending(this.OriginalLending.ID, Model.Archive.Lending.GetNewInstance(this.OriginalLending.ID, this.PersonnelNumber, person.ID, intentionComboBoxExtended.Text, dateDateControl.Text, timeTimeControl.Text, durationDayTextBoxExtended.IntValue.Value, durationHourTextBoxExtended.IntValue.Value, this.OriginalLending.ReturnDate, this.OriginalLending.ReturnTime, this.OriginalLending.RealDurationDay, this.OriginalLending.RealDurationHour, Setting.User.ThisProgram.GetCurrentUser <Model.Common.User>().Code.ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                PersianMessageBox.Show(this, "خطا در ثبت اطلاعات" + "\r\n\r\n" + ex.Message);
                return;
            }
            if (lendingID != 0)
            {
                ProgramEvents.OnLendingsChanged();
                this.Tag          = lendingID;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }
Exemplo n.º 11
0
        void deleteForm_DeleteAll(object sender, Njit.Program.Forms.DeleteForm.DeleteAllEventArgs e)
        {
            foreach (ListViewItem item in e.Items)
            {
                Model.Common.UserRoleReport obj = (Model.Common.UserRoleReport)item.Tag;

                Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
                dc.Connection.Open();
                dc.Transaction = dc.Connection.BeginTransaction();
                try
                {
                    if (obj.Locked)
                    {
                        throw new Exception("این گروه را نمیتوانید حذف کنید");
                    }
                    int userCount = Setting.User.ThisProgram.GetRoleMembershipCount(obj.Code);
                    if (userCount > 0)
                    {
                        throw new Exception("در این گروه " + userCount + " کاربر ثبت شده است");
                    }
                    var    query        = from temp in dc.UserRoles where temp.ID == obj.Code select temp;
                    var    userRole     = query.Single();
                    string originalName = userRole.Name;
                    Model.Common.UserRole.Delete(dc, userRole);
                    dc.SubmitChanges();
                    try
                    {
                        Setting.User.ThisProgram.AddLog(dc, Setting.User.UserOparatesPlaceNames.کاربران, Setting.User.UserOparatesNames.حذف, null, "حذف گروه کاربران '" + originalName + "'");
                    }
                    catch
                    {
                        throw new Exception("خطا در ذخیره عملکرد کاربر جاری");
                    }
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    dc.Transaction.Rollback();
                    dc.Connection.Close();
                    if (ex.ErrorCode == -2146232060 && ex.Number == 547)
                    {
                        e.ErrorList.Add("اطلاعات گروه  '" + obj.Name + "' قابل حذف نیست. از این اطلاعات در جای دیگر استفاده شده است");
                    }
                    else
                    {
                        e.ErrorList.Add("خطا در حذف اطلاعات گروه '" + obj.Name + "'" + Environment.NewLine + Environment.NewLine + ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    dc.Transaction.Rollback();
                    dc.Connection.Close();
                    e.ErrorList.Add("خطا در حذف اطلاعات گروه '" + obj.Name + "'" + Environment.NewLine + Environment.NewLine + ex.Message);
                }
                if (dc.Connection.State != ConnectionState.Closed)
                {
                    dc.Transaction.Commit();
                    dc.Connection.Close();
                }
            }
            ProgramEvents.OnUserRolesChanged();
        }