private void LoadData() { if (Request.QueryString["packageId"] != null) { int packageid = Convert.ToInt32(Request.QueryString["packageId"]); dk = new RegisterBUS(); DataTable dt = dk.GetByUserId(packageid); foreach (DataRow dr in dt.Rows) { lblTenGoi.Text = dr["packageName"].ToString(); packageFee = dr["totalFee"].ToString(); lblCost.Text = "Phí dịch vụ: " + packageFee + " $"; ; lbtotalfree.Text = dt.Rows[0]["totalFee"].ToString(); } } }
private double tinhtien() { double sum = 0; double a = Convert.ToDouble(DropDownList1.SelectedValue.ToString()); double b = Convert.ToDouble(lbtotalfree.Text); if (a > 1) { string sql = "SELECT * FROM tblpackageTime Where monthCount='" + a + "'"; SqlCommand cmd = new SqlCommand(sql, ConnectionData._MyConnection); cmd.CommandType = CommandType.Text; SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable table = new DataTable(); adapter.Fill(table); cmd.Dispose(); int discount; foreach (DataRow dr in table.Rows) { discount = Convert.ToInt32(dr["disCount"].ToString()); sum = ((b - (b * discount) / 100)*a); } } else { int packageid = Convert.ToInt32(Request.QueryString["packageId"]); dk = new RegisterBUS(); DataTable dt = dk.GetByUserId(packageid); foreach (DataRow dr in dt.Rows) { sum = Convert.ToInt32(dr["totalFee"].ToString()); } } return sum; }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { int fee = 0; if (Request.QueryString["packageId"] != null) { int packageid = Convert.ToInt32(Request.QueryString["packageId"]); dk = new RegisterBUS(); DataTable dt = dk.GetByUserId(packageid); foreach (DataRow dr in dt.Rows) { fee = Convert.ToInt32(dr["totalFee"].ToString()); } } int time = Convert.ToInt32(DropDownList1.SelectedValue); int sum = fee * time; double LastFee = tinhtien(); lblCost.Text = "Phí dịch vụ là: " + LastFee + " $"; }