Пример #1
0
        private void заявкаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormApplication app = new FormApplication();

            app.ShowDialog();
        }
Пример #2
0
        //Выбор заявки
        private void buttonPick_Click(object sender, EventArgs e)
        {
            FormApplication app = new FormApplication();

            app.toolStrip1.Visible         = false;
            app.dateTimePicker.Enabled     = false;
            app.comboBoxSeria.Enabled      = false;
            app.comboBoxAuto.Enabled       = false;
            app.comboBoxContragent.Enabled = false;
            app.textBoxCountAuto.ReadOnly  = true;
            app.ShowDialog();
            RequestID = app.getID();
            if (RequestID != "")
            {
                //Остаток
                selectCommand = "select AutoID from Application where ID='" + RequestID + "'";
                string AutoID = selectValue(ConnectionString, selectCommand).ToString();
                selectCommand = "select SUM(Count) from Entrance where date(Date) <= date('" + dateTimePicker.Value.ToString("yyyy-MM-dd") + "') AND AutoID ='" + AutoID + "'";
                string AutoEntrance = selectValue(ConnectionString, selectCommand).ToString();
                if (AutoEntrance == "")
                {
                    AutoEntrance = "0";
                }
                selectCommand = "select SUM(a.CountAuto) from Sale s JOIN Application a ON s.RequestID = a.ID where date(s.Date) <= date('" + dateTimePicker.Value.ToString("yyyy-MM-dd") + "') AND AutoID ='" + AutoID + "'";
                string AutoSale = selectValue(ConnectionString, selectCommand).ToString();
                if (AutoSale == "")
                {
                    AutoSale = "0";
                }
                int Ostatok = Convert.ToInt32(AutoEntrance) - Convert.ToInt32(AutoSale);
                selectCommand = "select CountAuto from Application where ID='" + RequestID + "'";
                string CountAuto = selectValue(ConnectionString, selectCommand).ToString();
                selectCommand = "select SaleCost from Service where ID = (select ServiceID from Application where ID = '" + RequestID + "')";
                if (Ostatok < Convert.ToInt32(CountAuto))
                {
                    MessageBox.Show("Остаток данной серии автомобилей составляет " + Ostatok + ". Продажа невозможна", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    comboBoxRequest.SelectedValue = RequestID;
                    selectCommand = "select SaleCost from Auto where ID = (select AutoID from Application where ID = '" + RequestID + "')";
                    AutoSum       = selectValue(ConnectionString, selectCommand).ToString();
                    selectCommand = "select SaleCost from Service where ID = (select ServiceID from Application where ID = '" + RequestID + "')";
                    ServiceSum    = selectValue(ConnectionString, selectCommand).ToString();
                    string CountService;
                    if (ServiceSum == "")
                    {
                        ServiceSum   = "0";
                        CountService = "0";
                    }
                    else
                    {
                        selectCommand = "select CountService from Application where ID = '" + RequestID + "'";
                        CountService  = selectValue(ConnectionString, selectCommand).ToString();
                    }
                    AutoSum         = (Convert.ToDecimal(AutoSum) * Convert.ToDecimal(CountAuto)).ToString();
                    ServiceSum      = (Convert.ToDecimal(ServiceSum) * Convert.ToDecimal(CountService)).ToString();
                    textBoxSum.Text = (Convert.ToDecimal(AutoSum) + Convert.ToDecimal(ServiceSum)).ToString();
                }
            }
        }