private void btnSave_Click(object sender, RoutedEventArgs e) { FundTypes ft = this.DataContext as FundTypes; SQLiteDatabase db = new SQLiteDatabase(); if (isEdit) { ft.Id = ftl.Id; Dictionary <string, string> dic1 = Utility.GetTypePropertyValues <FundTypes>(ft); string s = db.Update("FundType", dic1, " ID =" + Convert.ToString(ft.Id) + ""); db.ExecuteNonQuery(s); } else { Dictionary <string, string> dic1 = Utility.GetTypePropertyValues <FundTypes>(ft); dic1.Remove("Id"); string s = db.Insert("FundType", dic1); db.ExecuteNonQuery(s); } if (this.SaveButtonClick != null) { this.SaveButtonClick(this, e); } }
private void BtnExpSave_Click(object sender, RoutedEventArgs e) { Expense exp = this.DataContext as Expense; exp.ExpenseNo = txtExpNo.Text; SQLiteDatabase db = new SQLiteDatabase(); Expense eobj = exp; eobj.FundType = Convert.ToString(cbExpFundType.SelectedValue); eobj.TxnType = Convert.ToString(cbTxnType.SelectedValue); eobj.ExpDate = Convert.ToDateTime(eobj.ExpDate).ToSqlLiteDatetime(); if (IsExpEdit) { eobj.Modified = DateTime.Now.ToSqlLiteDatetime(); eobj.ModifiedBy = LoginUser.UName; eobj.Created = Convert.ToDateTime(exp.Created).ToSqlLiteDatetime(); eobj.CreatedBy = exp.CreatedBy; Dictionary <string, string> dic1 = Utility.GetTypePropertyValues <Expense>(eobj); string s = db.Update("Expenses", dic1, " ID =" + Convert.ToString(exp.ID) + ""); db.ExecuteNonQuery(s); } else { eobj.Created = DateTime.Now.ToSqlLiteDatetime(); eobj.CreatedBy = LoginUser.UName; Dictionary <string, string> dic1 = Utility.GetTypePropertyValues <Expense>(eobj); string s = db.Insert("Expenses", dic1); db.ExecuteNonQuery(s); } if (this.SaveButtonClick != null) { this.SaveButtonClick(this, e); } }
private void btnSaveDonation_Click(object sender, RoutedEventArgs e) { if (txtName.Text == "" || txtAmount.Text == "") { MessageBox.Show("Please enter Name and Amount."); return; } if (txtEmail.Text != "") { if (!Regex.IsMatch(txtEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { MessageBox.Show("Please enter correct Email"); return; } } if (txtPhone.Text != "") { if (!Regex.IsMatch(txtPhone.Text, @"[^0-9]+")) { MessageBox.Show("Please enter correct phone number"); return; } } /* * if (cbByType.SelectedItem != null) * { * if ((cbByType.SelectedItem as ComboBoxItem).Content.ToString() != "By Cash") * { * MessageBox.Show("Please Enter Neft/ DD / Check Number"); * return; * } * } */ db = new SQLiteDatabase(); Donation dobj = new Donation(); dobj.ReceiptNo = txtSLNo.Text;// dobj.Ddate = TxtDate.Text; dobj.Name = txtName.Text; dobj.Gender = (bool)rbfeMale.IsChecked ? "Female" : "Male"; dobj.Email = txtEmail.Text; dobj.Phone = txtPhone.Text; dobj.Place = txtPlace.Text; dobj.FundType = cbFundType.Text; dobj.Amount = Convert.ToDecimal((!string.IsNullOrWhiteSpace(txtAmount.Text) ? txtAmount.Text : "0")); dobj.BTNo = txtBNo.Text; dobj.Address = txtAddress.Text; dobj.Comment = txtComment.Text; dobj.AmountType = cbByType.Text; dobj.Place = txtPlace.Text; if (IsDonationEdit) { dobj.Modified = DateTime.Now.ToSqlLiteDatetime(); dobj.ModifiedBy = LoginUser.UName; dobj.Created = Convert.ToDateTime(SelectedItem.Created).ToSqlLiteDatetime(); dobj.CreatedBy = SelectedItem.CreatedBy; Dictionary <string, string> dic1 = GetTypePropertyValues <Donation>(dobj); string s = db.Update("Donations", dic1, " ReceiptNo =" + Convert.ToString(dobj.ReceiptNo) + ""); db.ExecuteNonQuery(s); } else { dobj.Created = DateTime.Now.ToSqlLiteDatetime(); dobj.CreatedBy = LoginUser.UName; Dictionary <string, string> dic1 = GetTypePropertyValues <Donation>(dobj); string s = db.Insert("Donations", dic1); db.ExecuteNonQuery(s); NextNumber = ""; } splAddDonation.Visibility = Visibility.Collapsed; splDonations.Visibility = Visibility.Visible; LoadData(); IsDonationEdit = false; FillDoantionForm(new Donation()); SelectedItem = null; }