protected void btnInsert_Click(object sender, EventArgs e) { FloatAmountDAL amountDAL = new FloatAmountDAL { ConnectionString = ConfigurationManager.ConnectionStrings["MySQLTest"].ToString() }; Amount TheAmount = new Amount(); TheAmount.PaymentstoOman = Convert.ToDouble(TxtAddPaymentAmount.Text); TheAmount.Dateofpayment = (TxtAddPaymentDate.Text == string.Empty) ? (DateTime?)null : DateTime.Parse(TxtAddPaymentDate.Text); amountDAL.InsertAmount(TheAmount); FetchAmount(); }
protected void GVAmount_RowUpdating(object sender, GridViewUpdateEventArgs e) { FloatAmountDAL amountDAL = new FloatAmountDAL { ConnectionString = ConfigurationManager.ConnectionStrings["MySQLTest"].ToString() }; Amount TheAmount = new Amount(); TheAmount.ID = Convert.ToInt32(GVAmount.DataKeys[e.RowIndex].Values["ID"].ToString()); TheAmount.PaymentstoOman = Convert.ToDouble((GVAmount.Rows[e.RowIndex].FindControl("TxtAmountPayment") as TextBox).Text); TheAmount.Dateofpayment = ((GVAmount.Rows[e.RowIndex].FindControl("TxtAmountPaymentDate") as TextBox).Text == string.Empty) ? (DateTime?)null : DateTime.Parse((GVAmount.Rows[e.RowIndex].FindControl("TxtAmountPaymentDate") as TextBox).Text); amountDAL.InsertAmount(TheAmount); GVAmount.EditIndex = -1; FetchAmount(); }