public string Recharge(string password, string isdn, string date, int duration, int val, string param) { string ret = ""; try { if (password.Equals("surprise_recharger")) { Recharge r = new Recharge(); r.isdn = isdn; r.date = Convert.ToDateTime(date); r.duration = duration; r.val = val; r.param = param; r.source = "surprise"; rechargeHandler.BeginInvoke(r, null, null); } else if (password.Equals("mtopup")) { Recharge r = new Recharge(); r.isdn = isdn; r.date = Convert.ToDateTime(date); r.duration = duration; r.val = val; r.param = param; r.source = "MTopUp"; rechargeHandler.BeginInvoke(r, null, null); } } catch (Exception ex) { ret = ex.Message; } return ret; }
private void HandleRecharge(Recharge r) { if (sqlSaveRecharge == null) { sqlSaveRecharge = new SqlCommand("sp_SaveRecharge"); sqlSaveRecharge.CommandType = CommandType.StoredProcedure; sqlSaveRecharge.Parameters.Add("@isdn", SqlDbType.VarChar, 8); sqlSaveRecharge.Parameters.Add("@date", SqlDbType.DateTime, 8); sqlSaveRecharge.Parameters.Add("@duration", SqlDbType.Int, 4); sqlSaveRecharge.Parameters.Add("@value", SqlDbType.Money, 8); sqlSaveRecharge.Parameters.Add("@balance", SqlDbType.Money, 8); sqlSaveRecharge.Parameters.Add("@param", SqlDbType.VarChar, 200); sqlSaveRecharge.Parameters.Add("@source", SqlDbType.VarChar, 10); } SqlConnection con = new SqlConnection(strCon); sqlSaveRecharge.Connection = con; try { con.Open(); if (r.isdn.StartsWith("976")) r.isdn = r.isdn.Remove(0, 3); sqlSaveRecharge.Parameters["@isdn"].Value = r.isdn; sqlSaveRecharge.Parameters["@date"].Value = r.date; sqlSaveRecharge.Parameters["@duration"].Value = r.duration; sqlSaveRecharge.Parameters["@value"].Value = r.val; sqlSaveRecharge.Parameters["@balance"].Value = r.balance; sqlSaveRecharge.Parameters["@param"].Value = r.param; sqlSaveRecharge.Parameters["@source"].Value = r.source; sqlSaveRecharge.ExecuteNonQuery(); } catch { } finally { con.Close(); } }