Example #1
0
        private void BtmOK_Click(object sender, EventArgs e)
        {
            using (UnitOfWork db = new UnitOfWork())
            {
                var companyId      = db.Companies.GetEntityByName(t => t.nvcName == cbCompanies.SelectedItem).intNumber;
                var locationId     = db.Locations.GetEntityByName(t => t.nvcName == cbLocations.SelectedItem).intNumber;
                var categoryId     = db.Categories.GetEntityByName(t => t.nvcName == cbCategories.SelectedItem).intNumber;
                var typeId         = db.TechnicalDocumentTypes.GetEntityByName(t => t.nvcName == cbType.SelectedItem).intNumber;
                var coDesigner     = tbCoDesigner.Text.Trim();
                var designerName   = tbDesignerName.Text.Trim();
                var revisionNumber = tbRevisionNumber.Text.Trim();
                var title          = txtTitle.Text.Trim();

                var technicalDocuments = db.TechnicalDocuments.GetByWhere(t =>
                                                                          t.intCompany == companyId && t.intLocation == locationId && t.intCategory == categoryId && t.intType == typeId).ToList();
                tabTechnicalDocuments tabTechnicalDocuments = new tabTechnicalDocuments();

                if (technicalDocuments.Count > 0)
                {
                    var last = technicalDocuments.Last();
                    tabTechnicalDocuments.intOrder = last.intOrder + 1;
                }
                else
                {
                    tabTechnicalDocuments.intOrder = 1;
                }
                tabTechnicalDocuments.bitSelect         = false;
                tabTechnicalDocuments.intCompany        = companyId;
                tabTechnicalDocuments.intLocation       = locationId;
                tabTechnicalDocuments.intCategory       = categoryId;
                tabTechnicalDocuments.intType           = typeId;
                tabTechnicalDocuments.nvcCoDesigner     = coDesigner;
                tabTechnicalDocuments.nvcPersonDesigner = designerName;
                tabTechnicalDocuments.nvcRevisionNumber = revisionNumber;
                tabTechnicalDocuments.nvcTitle          = title;

                db.TechnicalDocuments.Insert(tabTechnicalDocuments);
                db.Save();
                this.Close();
                TechnicalDocuments frmTechnicalDocuments = new TechnicalDocuments();
                frmTechnicalDocuments.RefreshList(tabTechnicalDocuments.intCompany,
                                                  tabTechnicalDocuments.intLocation, tabTechnicalDocuments.intCategory,
                                                  tabTechnicalDocuments.intType);
                DialogResult = DialogResult.OK;
                //if (technicalDocuments.Last().intOrder.ToString().Length == 4)
                //{
                //    RtlMessageBox.Show("سقف ورود این مستند پر شده است", "اخطار", MessageBoxButtons.OK,
                //        MessageBoxIcon.Warning);
                //}
                //else
                //{

                //}
            }
        }
        private void MenTechnicalDocuments_Click(object sender, EventArgs e)
        {
            if (!TechnicalDocuments.bolIsRunning)
            {
                ToolStripMenuItem menTechnicalDocuments = new ToolStripMenuItem();
                menTechnicalDocuments.Name   = "menTechnicalDocuments";
                menTechnicalDocuments.Text   = "مستندات";
                menTechnicalDocuments.Click += new System.EventHandler(this.MenTechnicalDocuments_Click);
                this.menWindows.DropDownItems.Add(menTechnicalDocuments);

                TechnicalDocuments frmTechnicalDocuments = new TechnicalDocuments();
                frmTechnicalDocuments.MdiParent    = this;
                frmTechnicalDocuments.setSettings  = this.setSettings;
                frmTechnicalDocuments.cnConnection = this.cnConnection;
                frmTechnicalDocuments.usUser       = this.usLogined;
                frmTechnicalDocuments.Show();
                frmTechnicalDocuments.WindowState = FormWindowState.Maximized;
            }
        }
        private void menTechnicalDocuments_Click(object sender, EventArgs e)
        {
            if (!TechnicalDocuments.bolIsRunning)
            {
                ToolStripMenuItem menWindowsTechnicalDocuments = new ToolStripMenuItem();
                menWindowsTechnicalDocuments.Name     = "menWindowsTechnicalDocuments";
                menWindowsTechnicalDocuments.Text     = "مستندات";
                menWindowsTechnicalDocuments.AutoSize = false;
                menWindowsTechnicalDocuments.Height   = 45;
                menWindowsTechnicalDocuments.Width    = 400;
                menWindowsTechnicalDocuments.Click   += new System.EventHandler(this.menWindowsTechnicalDocuments_Click);
                this.menWindows.DropDownItems.Add(menWindowsTechnicalDocuments);

                TechnicalDocuments frmTechnicalDocuments = new TechnicalDocuments();
                frmTechnicalDocuments.MdiParent       = this;
                frmTechnicalDocuments.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                frmTechnicalDocuments.Dock            = DockStyle.Fill;
                frmTechnicalDocuments.cnConnection    = this.cnConnection;
                frmTechnicalDocuments.usUser          = this.usLogined;
                frmTechnicalDocuments.Show();
            }
        }