protected void btnAddTemplate_Command(object sender, CommandEventArgs e) { var row = (sender as ImageButton).NamingContainer as GridViewRow; var txAmount = ((TextBox)row.FindControl("txAmount")).Text; var txTempFromDate = ((TextBox)row.FindControl("txTempFromDate")).Text; var txTempToDate = ((TextBox)row.FindControl("txTempToDate")).Text; var txTempName = ((TextBox)row.FindControl("txTempName")).Text; var chkTempAuto = ((CheckBox)row.FindControl("chkTempAuto")).Checked; var cmbTemtType = ((DropDownList)row.FindControl("cmbTemtType")).SelectedValue; if (txTempName.NotEmpty() && txTempFromDate.NotEmpty() && cmbTemtType != "-1") { var i = new MoneyTransactionTemplate { Active = true, Amount = txAmount.NotEmpty() ? txAmount.ToInteger() : 0, Auto = chkTempAuto, FromDate = txTempFromDate.ToDateTime(), Name = txTempName, TransactionType = cmbTemtType == "1" ? MonthlyTransactionType.Credit : MonthlyTransactionType.Debit, ToDate = txTempToDate.NotEmpty() ? txTempToDate.ToDateTime() : (DateTime?)null, }; DBController.DbMoney.Add(i); RefreshView(); } }
public void Add(MoneyTransactionTemplate i) { SqlItemList sqlItems = Get(i); SetInsertIntoSql(SynnDataProvider.TableNames.MoneyTransactionTemplatess, sqlItems); ExecuteSql(); }
public void Update(MoneyTransactionTemplate tmpl) { SqlItemList sqlItems = Get(tmpl); SetUpdateSql(SynnDataProvider.TableNames.MoneyTransactionTemplatess, sqlItems, new SqlItemList { new SqlItem { FieldName = "Id", FieldValue = tmpl.Id } }); ExecuteSql(); }
private SqlItemList Get(MoneyTransactionTemplate p) { var sqlItems = new SqlItemList(); sqlItems.Add(new SqlItem("Amount", p.Amount)); sqlItems.Add(new SqlItem("Active", p.Active)); sqlItems.Add(new SqlItem("Auto", p.Auto)); sqlItems.Add(new SqlItem("FromDate", p.FromDate)); sqlItems.Add(new SqlItem("ToDate", p.ToDate)); sqlItems.Add(new SqlItem("Name", p.Name)); sqlItems.Add(new SqlItem("TransactionType", p.TransactionType)); return(sqlItems); }