private void clientDGV_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (clientDGV.SelectedCells.Count > 0) { TabPage newTabPage = new TabPage(); currentClient = clientDGV.Rows[clientDGV.SelectedCells[0].RowIndex].DataBoundItem as cClient; clientControl newClient = new clientControl(currentClient); newTabPage.Controls.Add(newClient); newTabPage.Text = currentClient.fio; ListTab.TabPages.Insert(ListTab.TabCount, newTabPage); ListTab.SelectedTab = newTabPage; } }
private void fioComboBox_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && fioComboBox.SelectedValue != null) { currentClient = new cClient((int)fioComboBox.SelectedValue); editClient(); } if (fioComboBox.Text.Length > 3) { saveClient.Enabled = true; } else { saveClient.Enabled = false; } }
public void getClientList(string searchByAllFields = "") { db db; SQLiteDataReader dbRdr; cClient c; clients.Clear(); string query = "SELECT * FROM clients "; List <string> wheres = new List <string>(); if (searchByAllFields != "") { wheres.Add(String.Format("(fio || phone || address || passport) like '%{0}%'", searchByAllFields)); } if (wheres.Count > 0) { query += "WHERE " + string.Join(" AND ", wheres.ToArray()); } query += " ORDER BY fio"; db = new db(); try { if (!db.dbOpen()) { throw new Exception("Ошибка подключения к БД."); } dbRdr = db.getReader(query); while (dbRdr.Read()) { c = new cClient(); c.setClient(dbRdr); clients.Add(c); } dbRdr.Close(); db.dbClose(); } catch (Exception ex) { MessageBox.Show("Ошибка чтения из базы данных: " + ex.Message, "Ошибка базы данных", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { db.dbClose(); } }
listHire hireList = new listHire(); //список взятого оборудования для клиента public clientControl() { InitializeComponent(); currentClient = new cClient(); // initClient(); //Включить эту херню перед релизом и офнуть в клике по форме #region Rental Grid View bindsrcHire.DataSource = hireList.viewHireList;///список чего взял чел rentalDGV.AutoGenerateColumns = false; rentalDGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dgvDescription[] hireDGVdsc = new dgvDescription[] { new dgvDescription(0, "all_equip", "all_equip", "Что взял", 4), new dgvDescription(0, "megaDATE", "megaDATE", "С/По", 1), }; trash.makeDataGridColumns(rentalDGV, hireDGVdsc, true); rentalDGV.DataSource = bindsrcHire; //viewHire(); #endregion }
public winterRentalForm(cClient Client) { InitializeComponent(); currentClient = Client; #region Equipment Grid View equipmentList.getEquipmentList(currentHire.equipment_in_contract); bindsrcEquipment.DataSource = equipmentList.equipments; equipmentDGV.AutoGenerateColumns = false; equipmentDGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dgvDescription[] equipmentDGVdsc = new dgvDescription[] { new dgvDescription(0, "brand", "brand", "Марка", 130), new dgvDescription(0, "model", "model", "Модель", 130), new dgvDescription(0, "color", "color", "Цвет", 140), new dgvDescription(0, "size", "size", "Размер", 140), new dgvDescription(0, "number", "number", "Сер №", 140), new dgvDescription(0, "cost", "cost", "Стоимость", 140), }; trash.makeDataGridColumns(equipmentDGV, equipmentDGVdsc, true); equipmentDGV.DataSource = bindsrcEquipment; #endregion }
void clearClient() { currentClient = new cClient(); phoneText.Text = addressText.Text = passportText.Text = fioComboBox.Text = ""; rentalDGV.Rows.Clear(); }
public clientControl(cClient Client) { /* InitializeComponent(); * currentClient = Client; * editClient();*/ }
private void fioComboBox_SelectionChangeCommitted(object sender, EventArgs e) { currentClient = new cClient((int)fioComboBox.SelectedValue); editClient(); }
public cPrintContract(cClient client, equipmentList equipmentList, DateTimePicker startDateTime, DateTimePicker endDateTime, string pledge, double rent) { int startHours = startDateTime.Value.Hour; int startMin = startDateTime.Value.Minute; string startDay = startDateTime.Value.Date.ToString("dd-MM-yyyy"); string startDate = String.Format("с {0:00}:{1:00} {2} г., ", startHours, startMin, startDay); int endHours = endDateTime.Value.Hour; int endMin = endDateTime.Value.Minute; string endDay = endDateTime.Value.Date.ToString("dd-MM-yyyy"); string endDate = String.Format("по {0:00}:{1:00} {2} г.", endHours, endMin, endDay); int length = equipmentList.equipments.Count; string simb = ""; foreach (cEquipment i in equipmentList.equipments) { if (length != 1) { simb = ", "; } else { simb = ""; } brand += (!string.IsNullOrEmpty(i.brand)) ? i.brand + "(" + i.model + ")" + simb : ""; color += i.color + simb; size += i.size + simb; number += (!string.IsNullOrEmpty(i.number)) ? i.number + simb : ""; cost += i.cost; length--; } try { wordApp = new Word.Application(); doc = wordApp.Documents.Add(Application.StartupPath + @"\Dogovor_prokata_snaryazhenia.dotx"); trash.replaceBookmark(doc, "date", DateTime.Now.Date.ToString("dd MMMM yyyyг.")); trash.replaceBookmark(doc, "fio", " " + client.fio); trash.replaceBookmark(doc, "address", Environment.NewLine + client.address); trash.replaceBookmark(doc, "passport", Environment.NewLine + client.passport); trash.replaceBookmark(doc, "phone", client.phone); trash.replaceBookmark(doc, "brand", " " + brand); trash.replaceBookmark(doc, "color", " " + color); trash.replaceBookmark(doc, "size", " " + size); trash.replaceBookmark(doc, "number", " " + number); trash.replaceBookmark(doc, "cost", " " + String.Format("{0:N} руб.", cost)); trash.replaceBookmark(doc, "time", " " + startDate + endDate); trash.replaceBookmark(doc, "pledge", " " + pledge); trash.replaceBookmark(doc, "rent", " " + String.Format("{0:N} руб.", rent)); trash.replaceBookmark(doc, "date1", DateTime.Now.Date.ToString("dd MMMM yyyyг.")); wordApp.Visible = true; } catch { MessageBox.Show("Ошибка формирования счета", "", MessageBoxButtons.OK, MessageBoxIcon.Error); doc = null; wordApp = null; GC.Collect(); } }