private void SetGB(List <DataGridViewRow> rows = null) { SetCostumeDT(); if (rows == null || rows.Count == 0) { dateDTP.Value = DateTime.Now; costumeDGV.DataSource = costumeDT; return; } foreach (DataGridViewRow row in rows) { int costume_size_id = (int)DB.GetRowCol(row, "costume_size_id"); string costume_name = DB.GetRowCol(row, "costume_name").ToString(); string vendor = DB.GetRowCol(row, "vendor").ToString(); string size_name_num = DB.GetRowCol(row, "size_name_num").ToString(); DateTime returndate_shedule = (DateTime)DB.GetRowCol(row, "returndate_shedule"); int costume_price = Convert.ToInt32(DB.GetRowCol(row, "costume_price")); int costume_daily_price = (int)DB.GetRowCol(row, "costume_daily_price"); int rent_price = Controller.GetRentPrice(dateDTP.Value, returndate_shedule, costume_daily_price); int order_id = (int)DB.GetRowCol(row, "id_order"); costumeDT.Rows.Add(costume_size_id, costume_name, vendor, size_name_num, costume_price, costume_daily_price, rent_price, returndate_shedule, order_id); } costumeDGV.DataSource = costumeDT; clientCB.SelectedValue = DB.GetRowCol(rows[0], "client_id"); dateDTP.Value = (DateTime)DB.GetRowCol(rows[0], "date"); }
private void SetGB(DataGridViewRow row = null) { if (row == null) { return; } nameTypeTB.Text = DB.GetRowCol(row, "name").ToString(); }
private void SetGB(DataGridViewRow row = null) { if (row == null) { return; } sizeTB.Text = DB.GetRowCol(row, "name").ToString(); altSizeTB.Text = DB.GetRowCol(row, "numeric").ToString(); }
private void notPaidButton_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in mainDGV.SelectedRows) { int bill_id = (int)DB.GetRowCol(row, "id_bill"); string query = string.Format("UPDATE `bill` SET `paid` = 0 WHERE `id_bill` = {0}", bill_id); DB.SetNoResultQuery(query); } SetMainDGV(searchTB.Text); }
private void mainDGV_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (callerForm == null) { show("no add"); SetGB(mainDGV.SelectedRows[0]); return; } int costume_id = (int)DB.GetRowCol(mainDGV.SelectedRows[0], "id_costume"); }
private void SetGB(DataGridViewRow row = null) { if (row == null) { return; } nameTB.Text = DB.GetRowCol(row, "name").ToString(); priceTB.Text = DB.GetRowCol(row, "price").ToString(); daily_priceTB.Text = DB.GetRowCol(row, "daily_price").ToString(); DB.FillCB(typeCB, "SELECT * FROM carnaval.costume_type;", "id_costume_type", "name"); typeCB.SelectedIndex = Convert.ToInt32(DB.GetRowCol(row, "costume_type_id")) - 1; }
private void deleteButton_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection rows = mainDGV.SelectedRows; int n = rows.Count; string text; string caption; if (n == 1) { text = string.Format("Вы уверены, что хотите удалить размер костюма \n{0}?", DB.GetRowCol(rows[0], "costume_name")); caption = "Удаление размера костюма"; } else { Func <string> GetWordForm = () => { if (n % 100 >= 11 && n % 100 <= 19) { return("размеров костюмов"); } if (n % 10 == 1) { return("размер костюма"); } if (n % 10 >= 2 && n % 10 <= 4) { return("размера костюма"); } return("размеров костюмов"); }; text = string.Format("Вы уверены, что хотите удалить {0} {1}?", n, GetWordForm()); caption = "Удаление размеров костюмов"; } DialogResult answer = MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (answer == DialogResult.No) { return; } var ids = from DataGridViewRow x in rows select DB.GetRowCol(x, "id_costume_size"); string query = string.Format("DELETE FROM `costume_size` WHERE `id_costume_size` IN ({0})", string.Join(", ", ids)); DB.SetNoResultQuery(query); SetMainDGV(searchTB.Text); }
private void SetGB(DataGridViewRow row = null) { if (row == null) { return; } fioTB.Text = DB.GetRowCol(row, "name").ToString(); phoneTB.Text = DB.GetRowCol(row, "telephone").ToString(); adressTB.Text = DB.GetRowCol(row, "address").ToString(); passNumTB.Text = DB.GetRowCol(row, "id_passport").ToString(); passDateDTP.Value = (DateTime)DB.GetRowCol(row, "passport_issue"); passDepartRTB.Text = DB.GetRowCol(row, "passport_depart").ToString(); }
private void mainDGV_DoubleClick(object sender, EventArgs e) { if (costume != null) { int costume_id = (int)DB.GetRowCol(mainDGV.Rows[mainDGV.SelectedCells[0].RowIndex], "id_costume_type"); costume.typeCB.SelectedValue = costume_id; this.Close(); } else { SetGB(mainDGV.SelectedRows[0]); Show(); } }
private void SetGB(DataGridViewRow row = null) { DB.FillCB(costumeCB, Properties.Resources.CostumeQuery, "id_costume", "name"); DB.FillCB(sizeCB, Properties.Resources.SizeQuery, "id_size", "name_num"); amountTB.Text = "1"; if (row == null) { return; } curCS_id = (int)DB.GetRowCol(row, "id_costume_size"); costumeCB.SelectedValue = DB.GetRowCol(row, "costume_id"); sizeCB.SelectedValue = DB.GetRowCol(row, "size_id"); amountTB.Text = DB.GetRowCol(row, "amount").ToString(); }
private void deleteButton_Click(object sender, EventArgs e) //не доделал { DataGridViewSelectedRowCollection rows = mainDGV.SelectedRows; int n = rows.Count; string text; string caption; if (n == 1) { if (MessageBox.Show(String.Format("Вы уверены, что хотите удалить запись о костюме\n{0}?", mainDGV[0, mainDGV.CurrentRow.Index].Value.ToString()), "Внимание", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK) { string query = String.Format(@" DELETE FROM `carnaval`.`costume` WHERE id_costume={0};", DB.GetRowCol(mainDGV.Rows[mainDGV.SelectedCells[0].RowIndex], "id_costume")); DB.SetNoResultQuery(query); } refreshData(); } else { Func <string> GetWordForm = () => { if (n % 100 >= 11 && n % 100 <= 19) { return("записей"); } if (n % 10 == 1) { return("запись"); } if (n % 10 >= 2 && n % 10 <= 4) { return("записи"); } return("записей"); }; if (MessageBox.Show(String.Format("Вы уверены, что хотите удалить {0} {1} о клиентах?", n, GetWordForm()), "Внимание", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK) { var ids = from DataGridViewRow x in rows select DB.GetRowCol(x, "id_costume"); string query = string.Format("DELETE FROM `costume` WHERE `id_costume` IN ({0})", string.Join(", ", ids)); DB.SetNoResultQuery(query); refreshData(); } } }
private void OKButton_Click(object sender, EventArgs e) { returndateDTP.Value = new DateTime (returndateDTP.Value.Year, returndateDTP.Value.Month, returndateDTP.Value.Day); int dept; if (!Int32.TryParse(deptTB.Text, out dept)) { MessageBox.Show("Поля заполнены некорректно"); return; } string dt = DB.DateToMysql(returndateDTP.Value, true, false); var return_filter = from DataGridViewRow x in rows select(int) DB.GetRowCol(x, "id_order"); string return_query = string.Format("UPDATE `order` SET `returndate_actual` = '{0}' " + "WHERE `id_order` IN ({1})", dt, string.Join(", ", return_filter)); DB.SetNoResultQuery(return_query); // ИСПРАВИТЬ ВЫЧИСЛЕНИЕ СЧЕТА НА ВОЗВРАТ ДЕПОЗИТА var bill_return_filter = from DataGridViewRow x in rows select string.Format("('{0}', 2, {1}, {2}, {3}, 0)", dt, DB.GetRowCol(x, "id_order"), Program.employee_id, DB.GetRowCol(x, "costume_price")); string bill_return_query = string.Format("INSERT INTO `bill` (`date`, `bill_type_id`, `order_id`, " + "`employee_id`, `price`, `paid`) VALUES {0}", string.Join(", ", bill_return_filter)); DB.SetNoResultQuery(bill_return_query); var bill_filter = from DataGridViewRow x in rows where returndateDTP.Value > (DateTime)DB.GetRowCol(x, "returndate_shedule") select string.Format("('{0}', 3, {1}, {2}, {3}, 0)", dt, DB.GetRowCol(x, "id_order"), Program.employee_id, Controller.GetRentPrice((DateTime)DB.GetRowCol(x, "returndate_shedule"), returndateDTP.Value, dept)); if (bill_filter.Count() > 0) { string bill_query = string.Format("INSERT INTO `bill` (`date`, `bill_type_id`, `order_id`, " + "`employee_id`, `price`, `paid`) VALUES {0}", string.Join(", ", bill_filter)); DB.SetNoResultQuery(bill_query); } new BillForm(DB.GetRowCol(rows[0], "client_name").ToString()).Show(); Close(); }
private void mainDGV_DoubleClick(object sender, EventArgs e) { if (callerForm == null) { show("edit"); SetGB(mainDGV.SelectedRows[0]); return; } int client_id = (int)DB.GetRowCol(mainDGV.SelectedRows[0], "id_client"); Type formType = callerForm.GetType(); if (formType == typeof(OrderForm)) { (callerForm as OrderForm).clientCB.SelectedValue = client_id; } this.Close(); }
private void AddOrderCostume(DataGridViewRow row = null) // доделать { int costume_size_id = row == null ? curCS_id : (int)DB.GetRowCol(row, "id_costume_size"); string costume_name = row == null ? costumeCB.Text : DB.GetRowCol(row, "costume_name").ToString(); string vendor = ""; string size_name_num = row == null ? sizeCB.Text : DB.GetRowCol(row, "size_name_num").ToString(); int costume_price = row == null ? (int)(costumeCB.DataSource as DataTable).Rows[costumeCB.SelectedIndex]["price"] : (int)DB.GetRowCol(row, "costume_price"); int costume_daily_price = row == null ? (int)(costumeCB.DataSource as DataTable).Rows[costumeCB.SelectedIndex]["daily_price"] : (int)DB.GetRowCol(row, "costume_daily_price"); DateTime returndate_shedule = DateTime.Now.AddDays(7); orderForm.costumeDT.Rows.Add(costume_size_id, costume_name, vendor, size_name_num, costume_price, costume_daily_price, null, returndate_shedule, null); }
private void mainDGV_SelectionChanged(object sender, EventArgs e) { if (mainDGV.SelectedRows.Count == 0) { return; } int client_id = (int)DB.GetRowCol(mainDGV.SelectedRows[0], "client_id"); bool oneClient = true; foreach (DataGridViewRow row in mainDGV.SelectedRows) { if (client_id != (int)DB.GetRowCol(row, "client_id")) { oneClient = false; break; } } takeButton.Enabled = editButton.Enabled = oneClient; }
private void SetDGVStyle() { for (int i = 0; i < mainDGV.Rows.Count; i++) { mainDGV.Rows[i].HeaderCell.Value = (i + 1).ToString(); DateTime dtShedule; dtShedule = (DateTime)DB.GetRowCol(mainDGV.Rows[i], "returndate_shedule"); object objActual = DB.GetRowCol(mainDGV.Rows[i], "returndate_actual"); if (objActual.GetType() == typeof(DBNull)) { if (dtShedule < DateTime.Now) { mainDGV.Rows[i].DefaultCellStyle.BackColor = Color.Red; } } else { mainDGV.Rows[i].DefaultCellStyle.BackColor = Color.LightGray; } } }
private void OKButton_Click(object sender, EventArgs e) { if (sizeTB.Text.Trim(' ') == "" || altSizeTB.Text.Trim(' ') == "") { MessageBox.Show("Заполните все обязательные поля!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { string query; string size = sizeTB.Text, altSize = altSizeTB.Text; if (state == "add") { query = String.Format(@"INSERT INTO `carnaval`.`size` (`name`, `numeric`) VALUES ('{0}', '{1}');", size, altSize); } else { query = String.Format(@"UPDATE `carnaval`.`size` SET `name` = '{0}', `numeric` = '{1}' WHERE `id_size` = {2};", size, altSize, DB.GetRowCol(mainDGV.SelectedRows[0], "id_size").ToString()); } long inserted_id = DB.SetNoResultQuery(query); if (inserted_id > 0) { hide(); refreshData(); } else { MessageBox.Show("При добавлении размера произошла ошибка, \nобратитесь к системному администратору!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void OKButton_Click(object sender, EventArgs e) { if (nameTB.Text.Trim(' ') == "" || priceTB.Text.Trim(' ') == "" || typeCB.SelectedText.ToString() == null || daily_priceTB.Text.Trim(' ') == "") { MessageBox.Show("Заполните все обязательные поля!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { string priceCostume = priceTB.Text, daily_priceCostume = daily_priceTB.Text, typeCostume = typeCB.SelectedValue.ToString(), nameCostume = nameTB.Text.Replace("'", "\'"); string query; if (state == "add") { query = String.Format(@"INSERT INTO `carnaval`.`costume` (`name`, `costume_type_id`, `price`, `daily_price`) VALUES ('{0}', {1}, {2}, {3});", nameCostume, typeCostume, priceCostume, daily_priceCostume); } else { query = String.Format(@"UPDATE `carnaval`.`costume` SET `name` = '{0}', `costume_type_id` = '{1}', `price` = '{2}', `daily_price` = '{3}' WHERE `id_costume` = '{4}'; ", nameCostume, typeCostume, priceCostume, daily_priceCostume, DB.GetRowCol(mainDGV.SelectedRows[0], "id_costume").ToString()); } int inserted_id = DB.SetNoResultQuery(query); hide(); // mainDGV.Rows.Add(fio, phone); //focusOnRowDGV(); refreshData(); if (callerForm != null && callerForm.GetType() == typeof(CostumeSizeForm)) { CostumeSizeForm CSForm = (CostumeSizeForm)callerForm; DB.FillCB(CSForm.costumeCB, Properties.Resources.CostumeQuery, "id_costume", "name"); if (inserted_id != 0) { CSForm.costumeCB.SelectedValue = inserted_id; } Close(); } } }