Esempio n. 1
0
        //Форма нового документа
        private void CreateNewDocument()
        {
            try
            {
                string    DocNum;
                string    ServiceDate = System.DateTime.Now.ToShortDateString();
                string    DateIns     = System.DateTime.Now.ToString();
                string    GetDocNum   = "exec dbo.GetDocNum 1,'" + ServiceDate + "'";
                DataTable dt          = new DataTable();
                dt     = DbConnection.DBConnect(GetDocNum);
                DocNum = dt.Rows[0][0].ToString();

                string CreateDocHead = "exec dbo.RenderedServiceHeadCreate '" + DocNum + "', '" + ServiceDate + "','" + DateIns + "'";
                DbConnection.DBConnect(CreateDocHead);

                OrderAddForm OrderAddForm = new OrderAddForm(this.TabControlExtra);
                TabControlExtra.Show();
                TabPage OrderAddTabPage = new TabPage("Акт № " + DocNum + " от " + DateIns);
                OrderAddForm.GetStatus = DocNum;
                OrderAddForm.GetDate   = DateIns;
                TabControlExtra.TabPages.Add(OrderAddTabPage);
                TabControlExtra.SelectedTab  = OrderAddTabPage;
                OrderAddForm.TopLevel        = false;
                OrderAddForm.Visible         = true;
                OrderAddForm.FormBorderStyle = FormBorderStyle.None;
                OrderAddForm.Dock            = DockStyle.Fill;
                OrderAddTabPage.Controls.Add(OrderAddForm);
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                ArrayList rows = new ArrayList();

                List <Object> aList = new List <Object>();
                string        ID    = string.Empty;

                List <Object> CarnumList = new List <Object>();
                string        CarNum     = string.Empty;

                Int32[] selectedRowHandles = gridView3.GetSelectedRows();

                DateTime TodayDate = DateTime.Today;
                DateTime oDate     = Convert.ToDateTime(date);
                int      InTime    = (TodayDate - oDate).Days;

                if (selectedRowHandles.Length < gridView3.RowCount && InTime <= 14)
                {
                    for (int i = 0; i < selectedRowHandles.Length; i++)
                    {
                        int selectedRowHandle = selectedRowHandles[i];
                        if (selectedRowHandle >= 0)
                        {
                            rows.Add(gridView3.GetDataRow(selectedRowHandle));
                        }
                    }

                    foreach (DataRow row in rows)
                    {
                        aList.Add(row["ID"]);
                        ID = string.Join(" ", aList);

                        CarnumList.Add(row["Номер В/Ц"]);
                        CarNum = string.Join(" ", CarnumList);

                        Clipboard.SetText(CarNum);

                        string delete = "exec dbo.Remove_Rent_Carriage '" + ID + "','" + CarNum + "'";
                        DbConnection.DBConnect(delete);
                    }

                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType() == typeof(Change_of_Ownership))
                        {
                            form.Activate();
                            return;
                        }
                    }

                    string DateIns = System.DateTime.Now.ToString();

                    Change_of_Ownership change_Of_Ownership = new Change_of_Ownership(tabControl1, role, User_ID);
                    tabControl1.Show();
                    TabPage chg_tabPage = new TabPage("Смена собственника от " + DateIns);
                    change_Of_Ownership.GetDate = DateIns;
                    tabControl1.TabPages.Add(chg_tabPage);
                    tabControl1.SelectedTab             = chg_tabPage;
                    change_Of_Ownership.TopLevel        = false;
                    change_Of_Ownership.Visible         = true;
                    change_Of_Ownership.FormBorderStyle = FormBorderStyle.None;
                    change_Of_Ownership.Dock            = DockStyle.Fill;
                    chg_tabPage.Controls.Add(change_Of_Ownership);
                    change_Of_Ownership.вставитьToolStripMenuItem_Click(null, null);

                    gridView2_RowCellClick(null, null);
                }
                else
                {
                    if (selectedRowHandles.Length < gridView3.RowCount && InTime <= 14)
                    {
                        MessageBox.Show("В заявке должен быть хотябы 1 вагон", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        MessageBox.Show("Вагоны находящиеся в заявке сроком более 14 дней запрещены для создания заявки", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }