private void chargeAllToolStripMenuItem_Click(object sender, EventArgs e) { InputForms.InputForm iform = new InputForms.InputForm(new string[2] { "Year:", "Value:" }, "Charge", "Charge clients", 40, 150); string[] iformres = iform.Open(this); if (iformres != null) { if (MessageBox.Show(this, "Charge all clients " + iformres[1] + "€ for " + iformres[0] + "?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { Utility.database.OpenConnection(); SqlResault res = Utility.database.Query("select id from Clients"); for (int i = 0; i < res.Count; i++) { string cid = res[i]["id"]; SqlResault appartments = Utility.database.Query("select * from Appartments where client_id = " + cid + ";"); for (int j = 0; j < appartments.Count; j++) { Utility.database.Query(@"insert into Owes (client_id, appartment_id, aYear,mvalue,notes) values (" + cid + ", '" + appartments[j]["id"] + "' , '" + iformres[0] + "', " + iformres[1] + ", '');"); } } Utility.database.CloseConnection(); MessageBox.Show("All clients were charged for their appartments for the year " + iformres[0] + "."); } } }
private void payOffToolStripMenuItem_Click(object sender, EventArgs e) { if (owes_list.SelectedIndices.Count != 1) { return; } string owe_id = owes_list.SelectedItems[0].SubItems[6].Text; Utility.database.OpenConnection(); double current_owe = double.Parse(Utility.database.Query("select mvalue from Owes where id = " + owe_id + ";")[0]["mvalue"]); if (MessageBox.Show(this, Utility.CurrentLanguage["payment"] + ": " + current_owe + "€ ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { InputForms.InputForm F = new InputForms.InputForm(new string[1] { Utility.CurrentLanguage["pos:"] }, Utility.CurrentLanguage["ok"], Utility.CurrentLanguage["enter_pos"], 40, 150); string[] rs = F.Open(this); if (rs == null) { return; } Utility.database.Query("delete from Owes where id = " + owe_id + ";"); Utility.database.Query(@"insert into Payed (client_id, aDate, appartment_id, mvalue, pof, notes) values(" + client_id + ", '" + DateTime.Now.ToString("yyyy-MM-dd") + "', " + owes_list.SelectedItems[0].SubItems[5].Text + ", " + current_owe + ",'" + rs[0] + "', '');"); Utility.database.CloseConnection(); LoadFields(); } }
private void payed_list_DoubleClick(object sender, EventArgs e) { if (payed_list.SelectedIndices.Count != 1) { return; } InputForms.InputForm f = new InputForms.InputForm(new string[1] { Utility.CurrentLanguage["enter_a_nore"] }, Utility.CurrentLanguage["ok"], Utility.CurrentLanguage["note"], 130, 400); Utility.database.OpenConnection(); string payed_id = payed_list.SelectedItems[0].SubItems[7].Text; f.textboxes[0].Text = Utility.database.Query("select notes from Payed where id = " + payed_id + ";")[0]["notes"]; string[] f_res = f.Open(this); if (f_res != null) { string message = f_res[0]; Utility.database.Query("update Payed set notes = '" + message + "' where id=" + payed_id + ";"); Utility.database.CloseConnection(); LoadFields(); } }
private void payToolStripMenuItem_Click(object sender, EventArgs e) { if (owes_list.SelectedIndices.Count == 1) { InputForms.InputForm f = new InputForms.InputForm(new string[2] { Utility.CurrentLanguage["m_value:"], Utility.CurrentLanguage["pos:"] }, Utility.CurrentLanguage["ok"], Utility.CurrentLanguage["pay_for"] + owes_list.SelectedItems[0].SubItems[0].Text + " - " + owes_list.SelectedItems[0].SubItems[1].Text + " - " + owes_list.SelectedItems[0].SubItems[2].Text, 50, 200); string[] res = f.Open(this); if (res != null) { if (!Utility.IsDouble(res[0])) { MessageBox.Show("Please complete the fields correctly."); return; } if (MessageBox.Show(this, "Pay: " + res[0] + "€ ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { Utility.database.OpenConnection(); string owe_id = owes_list.SelectedItems[0].SubItems[6].Text; double current_owe = double.Parse(Utility.database.Query("select mvalue from Owes where id = " + owe_id + ";")[0]["mvalue"]); double value_to_pay = double.Parse(res[0]); if (current_owe - value_to_pay <= 0) { Utility.database.Query("delete from Owes where id = " + owe_id + ";"); } else { Utility.database.Query("update Owes set mvalue = " + (current_owe - value_to_pay) + " where id =" + owe_id + ";"); } Utility.database.Query(@"insert into Payed (client_id, aDate, appartment_id, mvalue, pof, notes) values(" + client_id + ", '" + DateTime.Now.ToString("yyyy-MM-dd") + "', " + owes_list.SelectedItems[0].SubItems[5].Text + ", " + res[0] + ",'" + res[1] + "', '');"); Utility.database.CloseConnection(); LoadFields(); } } } }