protected void btnlnkEstimate_Click(object sender, EventArgs e) { lblRegisterError.Text = ""; lblReturnMessage.Text = ""; lblYouGet.Text = ""; lblYouReturn.Text = ""; if (txtCollectionDate.Text == "") { lblRegisterError.Text = "Please Select collection Date."; } else if (txtQuantity.Text == "") { lblRegisterError.Text = "Please provide Quantity."; } else if (Convert.ToInt32(txtQuantity.Text) < 1) { lblRegisterError.Text = "Quantity cannot be lessthan 1."; } else if (ddlConditon.SelectedIndex == 0) { lblRegisterError.Text = "Please select Conditon type."; } else { CricketSystemEntities context = new CricketSystemEntities(); pawn_table tbl = new pawn_table(); int prod_id = Convert.ToInt32(lblItemId.Text); int userid = Convert.ToInt32(Session["userId"].ToString()); string collectionDate = txtCollectionDate.Text; int Quantity = Convert.ToInt32(txtQuantity.Text); string condition = ddlConditon.SelectedValue; double fee = Convert.ToDouble(txtAmount.Text); double ammountdue = 0; double topay = 0; if (ddlConditon.SelectedIndex == 1) { topay = Quantity * fee * 0.7; ammountdue = topay + (topay * 0.29); } else if (ddlConditon.SelectedIndex == 2) { topay = Quantity * fee * 0.6; ammountdue = topay + (topay * 0.32); } else { topay = Quantity * fee * 0.45; ammountdue = topay + (topay * 0.35); } ammountdue = Math.Round(ammountdue, 2); topay = Math.Round(topay, 2); lblReturnMessage.Text = "The item(s) will be kept for not more than 90 days"; lblYouGet.Text = "Amount you will get R" + topay; lblYouReturn.Text = "Amount you must return R" + ammountdue; } }
protected void btnUpdateProfile_Click(object sender, EventArgs e) { lblRegisterError.Text = ""; //lblReturnMessage.Text = ""; //lblYouGet.Text = ""; //lblYouReturn.Text = ""; if (txtCollectionDate.Text == "") { lblRegisterError.Text = "Please Select collection Date."; } else if (txtQuantity.Text == "") { lblRegisterError.Text = "Please provide Quantity."; } else if (ddlConditon.SelectedIndex == 0) { lblRegisterError.Text = "Please select Conditon type."; } else if (lblReturnMessage.Text == "") { lblRegisterError.Text = "Please 'Get Estimation' before you proceed."; } else { CricketSystemEntities context = new CricketSystemEntities(); pawn_table tbl = new pawn_table(); int prod_id = Convert.ToInt32(lblItemId.Text); int userid = Convert.ToInt32(Session["userId"].ToString()); string collectionDate = txtCollectionDate.Text; int Quantity = Convert.ToInt32(txtQuantity.Text); string condition = ddlConditon.SelectedValue; double fee = Convert.ToDouble(txtAmount.Text); double ammountdue = 0; double topay = 0; if (ddlConditon.SelectedIndex == 1) { topay = Quantity * fee * 0.7; ammountdue = topay + (topay * 0.29); } else if (ddlConditon.SelectedIndex == 2) { topay = Quantity * fee * 0.6; ammountdue = topay + (topay * 0.32); } else { topay = Quantity * fee * 0.45; ammountdue = topay + (topay * 0.35); } tbl.Pawn_Product_id = prod_id; tbl.User_id = userid; tbl.Quantity = Quantity; tbl.LoanAmount = Convert.ToDecimal(topay); tbl.AmountDue = Convert.ToDecimal(ammountdue); tbl.Status = "Pending"; tbl.Condition = condition; tbl.Date = DateTime.Now.ToShortDateString(); tbl.Time = DateTime.Now.ToShortTimeString(); tbl.collectionDate = collectionDate; context.pawn_table.Add(tbl); context.SaveChanges(); Response.Redirect("Pawn.aspx"); } }