private void Save_Click(object sender, EventArgs e) { MySqlCommand _MySqlSelectCommand; _MySqlSelectCommand = new MySqlCommand(); _MySqlSelectCommand.Connection = Gar.MySqlCon; if (this.Id_car == 0) { // получим очередной номер this.Id_car = Gar.GetNN("car"); _MySqlSelectCommand.CommandText = "INSERT INTO car (Id_car, Brand, Model, Gov_numb, Id_customer) VALUES(@ID, @BRAND, @MODEL, @GOV, @CUSTOMER)"; } else { _MySqlSelectCommand.CommandText = "UPDATE car SET Brand = @BRAND, Model = @MODEL, Gov_numb = @GOV, Id_customer = @CUSTOMER WHERE Id_car = @ID"; } _MySqlSelectCommand.Parameters.AddWithValue("@ID", this.Id_car); _MySqlSelectCommand.Parameters.AddWithValue("@BRAND", this.Brand.Text); _MySqlSelectCommand.Parameters.AddWithValue("@MODEL", this.Model.Text); _MySqlSelectCommand.Parameters.AddWithValue("@GOV", this.Gov_numb.Text); _MySqlSelectCommand.Parameters.AddWithValue("@CUSTOMER", this.Customer.SelectedValue); int rowEffected = _MySqlSelectCommand.ExecuteNonQuery(); this.Dispose(); }
private void Save_Click(object sender, EventArgs e) { MySqlCommand _MySqlSelectCommand; _MySqlSelectCommand = new MySqlCommand(); _MySqlSelectCommand.Connection = Gar.MySqlCon; if (this.Id_client == 0) { // получим очередной номер this.Id_client = Gar.GetNN("customer"); _MySqlSelectCommand.CommandText = "INSERT INTO customer (Id_customer, name, lastname, middlename, phone) VALUES(@ID, @NAME, @LNAME, @MNAME, @PHONE)"; } else { _MySqlSelectCommand.CommandText = "UPDATE customer SET name = @NAME, lastname = @LNAME, middlename = @MNAME, phone = @PHONE WHERE Id_customer = @ID"; } _MySqlSelectCommand.Parameters.AddWithValue("@ID", this.Id_client); _MySqlSelectCommand.Parameters.AddWithValue("@NAME", this.Name.Text); _MySqlSelectCommand.Parameters.AddWithValue("@LNAME", this.LastName.Text); _MySqlSelectCommand.Parameters.AddWithValue("@PHONE", this.Phone.Text); _MySqlSelectCommand.Parameters.AddWithValue("@MNAME", this.PatrName.Text); int rowEffected = _MySqlSelectCommand.ExecuteNonQuery(); this.Dispose(); }
private void OK_Click(object sender, EventArgs e) { MySqlCommand _MySqlSelectCommand; _MySqlSelectCommand = new MySqlCommand(); _MySqlSelectCommand.Connection = Gar.MySqlCon; if (this.Id_glass == 0) { // получим очередной номер this.Id_glass = Gar.GetNN("glass"); _MySqlSelectCommand.CommandText = "INSERT INTO glass (Id_glass, Name, Price, Provider, Eurocode) VALUES(@ID, @NAME, @PRICE, @PROVIDER, @CODE)"; } else { _MySqlSelectCommand.CommandText = "UPDATE glass SET Name = @NAME, Price = @PRICE, Provider = @PROVIDER, Eurocode = @CODE WHERE Id_glass = @ID"; } _MySqlSelectCommand.Parameters.AddWithValue("@ID", this.Id_glass); _MySqlSelectCommand.Parameters.AddWithValue("@NAME", this.Name.Text); _MySqlSelectCommand.Parameters.AddWithValue("@PRICE", this.Price.Value); _MySqlSelectCommand.Parameters.AddWithValue("@PROVIDER", this.Provider.Text); _MySqlSelectCommand.Parameters.AddWithValue("@CODE", this.Eurocode.Text); int rowEffected = _MySqlSelectCommand.ExecuteNonQuery(); this.Dispose(); }
private void Save_Click(object sender, EventArgs e) { MySqlCommand _MySqlSelectCommand; _MySqlSelectCommand = new MySqlCommand(); _MySqlSelectCommand.Connection = Gar.MySqlCon; if (this.Id_service == 0) { // получим очередной номер this.Id_service = Gar.GetNN("service"); _MySqlSelectCommand.CommandText = "INSERT INTO service (Id_service, Name, Price) VALUES(@ID, @NAME, @PRICE)"; } else { _MySqlSelectCommand.CommandText = "UPDATE service SET Name = @NAME, Price = @PRICE WHERE Id_service = @ID"; } _MySqlSelectCommand.Parameters.AddWithValue("@ID", this.Id_service); _MySqlSelectCommand.Parameters.AddWithValue("@PRICE", this.Price.Value); _MySqlSelectCommand.Parameters.AddWithValue("@NAME", this.Name.Text); int rowEffected = _MySqlSelectCommand.ExecuteNonQuery(); this.Dispose(); }
private void OrderEdit_Load(object sender, EventArgs e) { this.vcar1TableAdapter.Fill(this.garageDataSet.vcar1); // Заполним данные по списку автомобилей this.staffTableAdapter.Fill(this.garageDataSet.staff); // Заполним данные по списку сотрудников this.serviceTableAdapter.Fill(this.garageDataSet.service); // Заполним данные по списку работ this.vglassTableAdapter.Fill(this.garageDataSet.vglass); // Заполним данные по списку запчастей this.Status.DataSource = Gar.StatusOrderList; this.Status.DisplayMember = "DL"; this.Status.ValueMember = "KY"; if (this.Id_order > 0) { this.NewOrder = false; // Редактирование MySqlCommand _MySqlSelectCommand; MySqlDataReader _Reader; _MySqlSelectCommand = new MySqlCommand(); _MySqlSelectCommand.Connection = Gar.MySqlCon; _MySqlSelectCommand.CommandText = "SELECT Id_car, Id_staff, Date_plan, Date_complete, Note, Status, `Sum` FROM `order` where Id_order = @ID"; _MySqlSelectCommand.Parameters.AddWithValue("@ID", this.Id_order); _Reader = _MySqlSelectCommand.ExecuteReader(); _Reader.Read(); if (_Reader.HasRows) { this.Car.SelectedValue = _Reader.GetInt32(0); this.Staff.SelectedValue = _Reader.GetInt32(1); this.Date_Plan.Value = _Reader.GetMySqlDateTime(2).Value; this.Date_Complete.Value = _Reader.GetMySqlDateTime(3).Value; this.Note.Text = _Reader.GetString(4); this.Status.SelectedValue = _Reader.GetString(5); this.OrderSUM.Text = _Reader.GetDecimal(6).ToString(); } _Reader.Close(); } else { this.NewOrder = true; // получим очередной номер заказа this.Id_order = Gar.GetNN("order"); this.Status.SelectedValue = Gar.StatusOrderFirst; } // Заполним данные по списку работ заказа this.order_serviceTableAdapter.FillBy(this.garageDataSet.order_service, this.Id_order); // Заполним данные по списку запчастей заказа this.order_glassTableAdapter.FillBy(this.garageDataSet.order_glass, this.Id_order); CALC_ITOG(); }
private void OK_Click(object sender, EventArgs e) { MySqlCommand _MySqlSelectCommand; _MySqlSelectCommand = new MySqlCommand(); _MySqlSelectCommand.Connection = Gar.MySqlCon; if (this.Id_master == 0) { // получим очередной номер this.Id_master = Gar.GetNN("staff"); _MySqlSelectCommand.CommandText = "INSERT INTO staff (Id_staff, Name, Login, Phone, Password, Type) VALUES (@ID, @NAME, @LOGIN, @PHONE, @PAW, @TYPE)"; } else { _MySqlSelectCommand.CommandText = "UPDATE staff SET Name = @NAME, Login = @LOGIN, Phone = @PHONE, Password = @PAW, Type = @TYPE WHERE Id_staff = @ID"; } _MySqlSelectCommand.Parameters.AddWithValue("@ID", this.Id_master); _MySqlSelectCommand.Parameters.AddWithValue("@NAME", this.Name.Text); _MySqlSelectCommand.Parameters.AddWithValue("@LOGIN", this.Login.Text); _MySqlSelectCommand.Parameters.AddWithValue("@PHONE", this.Phone.Text); _MySqlSelectCommand.Parameters.AddWithValue("@PAW", this.Passport.Text); if (this.Type.Checked) { _MySqlSelectCommand.Parameters.AddWithValue("@TYPE", "1"); } else { _MySqlSelectCommand.Parameters.AddWithValue("@TYPE", "0"); } int rowEffected = _MySqlSelectCommand.ExecuteNonQuery(); this.Dispose(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Boolean YesConn; Gar.Gar_Exit = false; /// Получим параметры GARAGE.CurP o = new GARAGE.CurP(); if (File.Exists(Application.StartupPath + @"\Garage.config")) { FEServerConfig.LoadSettings(ref o); Gar.IP_MySQL = o.IP_MySQL; // адрес сервера Gar.MySQL_username = o.MySQL_username; // имя пользователя Gar.MySQL_password = o.MuSQL_password; // пароль пользователя } else { // не найден файл параметров, будем создавать Gar.IP_MySQL = ""; // адрес сервера Gar.MySQL_username = ""; // имя пользователя Gar.MySQL_password = ""; // пароль пользователя Config FormConfig = new Config(); FormConfig.ShowDialog(); } Gar.MySqlCon = new MySqlConnection(); YesConn = false; // Будем запрашивать конфигурацию сервера БД пока не подключимся или не выйдем while ((YesConn == false) && (Gar.Gar_Exit != true)) { try { Gar.MySqlCon.ConnectionString = "database=garage;server=" + Gar.IP_MySQL + ";Username="******";pwd=" + Gar.MySQL_password; Gar.MySqlCon.Open(); if (Gar.DBConnectionStatus() == false) { YesConn = false; } else { YesConn = true; } } catch { YesConn = false; } if (!YesConn) { Config FormConfig = new Config(); FormConfig.ShowDialog(); } } // Авторизация AuthScreen FormAuth = new AuthScreen(); FormAuth.ShowDialog(); if (!Gar.Gar_Exit) { //Заполним классификатор статусов заказа Gar.StatusOrderList.Add(new UDCS("B", "Черновик")); } Gar.StatusOrderList.Add(new UDCS("W", "В работе")); Gar.StatusOrderList.Add(new UDCS("D", "Выполнен")); Gar.StatusOrderList.Add(new UDCS("C", "Отменен")); Application.Run(new MainScreen()); }