private void buttonAddUser_Click(object sender, EventArgs e) { if (textBoxNewUsername.Text == String.Empty || textBoxNewPassword.Text == String.Empty) { return; } string pass = MyUtills.ConvertToMd5(textBoxNewPassword.Text); bool res = localInterface.InsertSql("INSERT INTO users (username,password,type) VALUES ('" + textBoxNewUsername.Text + "','" + pass + "','" + comboBoxUserTypes.SelectedValue + "')"); if (res == true) { showUsers(); } }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (textBoxNew.Text == "") { MessageBox.Show("יש להזין שם ספק חדש", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading); return; } try { string sqlCmd = "INSERT INTO suppliers (name) VALUES ('" + textBoxNew.Text.Replace("'", "\\'") + "')"; localInterface.InsertSql(sqlCmd); showSuppliers(""); MessageBox.Show("ספק חדש נוסף בהצלחה", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading); } catch { } }
private void buttonSave_Click(object sender, EventArgs e) { string query; if (radioButtonSingle.Checked) { double amount; if (!Double.TryParse(textBoxAmountSingle.Text, out amount)) { return; } DataTable dt = localInterface.Select("SELECT id FROM expenses WHERE idSupplier='" + comboBoxSuppliers.SelectedValue.ToString() + "' AND date='" + MyUtills.dateToSQL(dateTimePickerSingle.Value) + "' AND amount='" + amount.ToString() + "'").Tables[0]; if (dt.Rows.Count > 0) { MessageBox.Show("תשלום זהה קיים כבר", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading); return; } query = "INSERT INTO expenses (date,amount,idSupplier,type,notes) VALUES ('" + MyUtills.dateToSQL(dateTimePickerSingle.Value) + "','" + amount.ToString() + "','" + comboBoxSuppliers.SelectedValue.ToString() + "','1','" + textBoxNotesSingle.Text + "')"; localInterface.InsertSql(query); } else if (radioButtonDebit.Checked) { double amount; if (!Double.TryParse(textBoxAmountDebit.Text, out amount)) { return; } int interval = 0; switch (comboBoxDebitInterval.SelectedIndex) { case 0: interval = 1; break; case 1: interval = 2; break; case 2: interval = 3; break; case 3: interval = 6; break; case 4: interval = 12; break; } int duration = 0; switch (comboBoxDebitDuration.SelectedIndex) { case 0: duration = 3; break; case 1: duration = 6; break; case 2: duration = 12; break; case 3: duration = 24; break; case 4: duration = 36; break; case 5: duration = 60; break; } if (interval > duration) { MessageBox.Show("משך התקופה חייב להיות גדול מזמן החזרה", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading); return; } DateTime newdate; DataTable newdt; for (int i = 0; i < duration; i += interval) { newdate = dateTimePickerDebit.Value.AddMonths(i); newdt = localInterface.Select("SELECT id FROM expenses WHERE idSupplier='" + comboBoxSuppliers.SelectedValue.ToString() + "' AND date='" + MyUtills.dateToSQL(newdate) + "' AND amount='" + amount.ToString() + "'").Tables[0]; if (newdt.Rows.Count > 0) { MessageBox.Show("אחד או יותר מהתשלומים כבר קיימים", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading); return; } } for (int i = 0; i < duration; i += interval) { newdate = dateTimePickerDebit.Value.AddMonths(i); query = "INSERT INTO expenses (date,amount,idsupplier,approved,type,notes) VALUES ('" + MyUtills.dateToSQL(newdate) + "','" + amount + "','" + comboBoxSuppliers.SelectedValue.ToString() + "',1,3,'" + newdate.ToString("MMMM") + "')"; localInterface.InsertSql(query); } } else if (radioButtonConst.Checked) { double amount; if (!Double.TryParse(textBoxAmountDebit.Text, out amount)) { return; } int interval = 0; switch (comboBoxDebitInterval.SelectedIndex) { case 0: interval = 1; break; case 1: interval = 2; break; case 2: interval = 3; break; case 3: interval = 6; break; case 4: interval = 12; break; } int duration = 0; switch (comboBoxDebitDuration.SelectedIndex) { case 0: duration = 3; break; case 1: duration = 6; break; case 2: duration = 12; break; case 3: duration = 24; break; case 4: duration = 36; break; case 5: duration = 60; break; } if (interval > duration) { MessageBox.Show("משך התקופה חייב להיות גדול מזמן החזרה", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading); return; } DateTime newdate; DataTable newdt; for (int i = 0; i < duration; i += interval) { newdate = dateTimePickerDebit.Value.AddMonths(i); newdt = localInterface.Select("SELECT id FROM expenses WHERE idSupplier='" + comboBoxSuppliers.SelectedValue.ToString() + "' AND date='" + MyUtills.dateToSQL(newdate) + "' AND amount='" + amount.ToString() + "'").Tables[0]; if (newdt.Rows.Count > 0) { MessageBox.Show("אחד או יותר מהתשלומים כבר קיימים", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading); return; } } for (int i = 0; i < duration; i += interval) { newdate = dateTimePickerDebit.Value.AddMonths(i); localInterface.InsertSql("INSERT INTO expenses (date,amount,idsupplier,approved,type,notes) VALUES ('" + MyUtills.dateToSQL(newdate) + "','" + amount + "','" + comboBoxSuppliers.SelectedValue.ToString() + "',0,2,'" + newdate.ToString("MMMM") + "')"); } } showExpenses(); }