示例#1
0
        private static void rollBack(string[][] programs)
        {
            for (int i = 0; i < programs.Length; i++)
            {
                switch (programs[i][0])
                {
                case "1":
                    webService.Service1Client client1 = new webService.Service1Client();

                    if (programs[i][3] != null)
                    {
                        client1.rollBack(programs[i][2], int.Parse(programs[i][3]));
                    }
                    break;

                case "2":

                    WebService3.Service1Client client2 = new WebService3.Service1Client();
                    if (programs[i][3] != null)
                    {
                        client2.rollBack(programs[i][2], int.Parse(programs[i][3]));
                    }
                    break;

                default:
                    break;
                }
            }
        }
        protected void otpbtn_Click(object sender, EventArgs e)
        {
            string otp      = otptxt.Text;
            string username = unametxt.Value;
            int    userID   = -1;

            if (Session["id"] != null)
            {
                int.TryParse(clsRidjindalEncryption.Decrypt(Session["id"].ToString(), "P@ssword", "123", "SHA1", 2, "%1234567890@#$%^", 256), out userID);
            }

            try
            {
                int n;
                if (Request.QueryString["p"] != null && int.TryParse(Request.QueryString["p"], out n))
                {
                    programName = int.Parse(Request.QueryString["p"]);
                }
                else
                {
                    programName = int.Parse(programID.Value);
                }

                string result = "";

                switch (id)
                {
                case 1:
                    webService.Service1Client c = new webService.Service1Client();
                    result = c.Loyalty_Program_Otp(unametxt.Value, hiddenPWD.Value, mobiletxt.Value, otptxt.Text)[0];
                    if (result != "0000")
                    {
                        messages.Text = "Error";
                    }
                    else
                    {
                        messages.Text = "Success";
                        int points = c.LP_UpdateUserInfo(unametxt.Value, hiddenPWD.Value);


                        SqlConnection con = new SqlConnection(Login.GetConnectionString());
                        con.Open();
                        SqlCommand cmd = new SqlCommand();
                        string     Sql = "INSERT INTO [dbo].[LH_Programs]([User_Id],[Username],[Password],[Points],[Create_Date],[Update_Date],[program],[mobile])"
                                         + "VALUES(@userID,@username,@password,@points,@date,@date,@programName,@mobile)";
                        cmd.Parameters.AddWithValue("@userID", userID);
                        cmd.Parameters.AddWithValue("@username", unametxt.Value);
                        cmd.Parameters.AddWithValue("@password", hiddenPWD.Value);
                        cmd.Parameters.AddWithValue("@points", points);
                        cmd.Parameters.AddWithValue("@date", DateTime.Now);
                        cmd.Parameters.AddWithValue("@programName", programName);
                        cmd.Parameters.AddWithValue("@mobile", mobiletxt.Value);
                        cmd.Connection  = con;
                        cmd.CommandText = Sql;
                        cmd.ExecuteNonQuery();
                        con.Close();

                        //con.Open();

                        //Sql = "update LH_user set LHP = LHP+@p where id = @userID";

                        //cmd = new SqlCommand(Sql, con);

                        //cmd.Parameters.AddWithValue("@p",int.Parse(Session["LHP"].ToString()));
                        //cmd.Parameters.AddWithValue("@userID",userID);
                        //cmd.ExecuteReader();
                        //con.Close();
                        Response.Redirect("Product.aspx");
                    }
                    break;

                case 2:
                    WebService3.Service1Client c3 = new WebService3.Service1Client();
                    result = c3.Loyalty_Program_Otp(unametxt.Value, hiddenPWD.Value, mobiletxt.Value, otptxt.Text)[0];
                    if (result != "0000")
                    {
                        messages.Text = "Error";
                    }
                    else
                    {
                        messages.Text = "Success";
                        int points = c3.LP_UpdateUserInfo(unametxt.Value, hiddenPWD.Value);
                        //int userID = ;//add the user ID from Session

                        SqlConnection con = new SqlConnection(Login.GetConnectionString());
                        con.Open();
                        SqlCommand cmd = new SqlCommand();
                        string     Sql = "INSERT INTO [dbo].[LH_Programs]([User_Id],[Username],[Password],[Points],[Create_Date],[Update_Date],[program],[mobile])"
                                         + "VALUES(@userID,@username,@password,@points,@date,@date,@programName,@mobile)";
                        cmd.Parameters.AddWithValue("@userID", userID);
                        cmd.Parameters.AddWithValue("@username", unametxt.Value);
                        cmd.Parameters.AddWithValue("@password", hiddenPWD.Value);
                        cmd.Parameters.AddWithValue("@points", points);
                        cmd.Parameters.AddWithValue("@date", DateTime.Now);
                        cmd.Parameters.AddWithValue("@programName", programName);
                        cmd.Parameters.AddWithValue("@mobile", mobiletxt.Value);
                        cmd.Connection  = con;
                        cmd.CommandText = Sql;
                        cmd.ExecuteReader();
                        con.Close();
                        Response.Redirect("Product.aspx");
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                messages.Text = ex.Message;
            }
        }
示例#3
0
        public static string AddProceed1(int userid, string[][] products, string[][] programs)
        {
            try
            {
                webService.Service1Client  client1 = new webService.Service1Client();
                WebService3.Service1Client client2 = new WebService3.Service1Client();
                for (int i = 0; i < programs.Length; i++)
                {
                    switch (programs[i][0])
                    {
                    case "1":

                        int result1 = client1.subtract(programs[i][2], int.Parse(programs[i][1]));
                        if (result1 == -1)
                        {
                            //rollBack
                            rollBack(programs);

                            return("general error in STC program ");
                        }
                        else if (result1 == -2)
                        {
                            //rollBack
                            rollBack(programs);

                            return("Insufficient Points for STC program ");
                        }
                        else
                        {
                            programs[i][3] = result1.ToString();
                        }
                        break;

                    case "2":
                        int result2 = client2.subtract(programs[i][2], int.Parse(programs[i][1]));
                        if (result2 == -1)
                        {
                            //rollBack
                            rollBack(programs);
                            return("general error in Delta program ");
                        }
                        else if (result2 == -2)
                        {
                            //rollBack
                            rollBack(programs);
                            return("Insufficient Points for Delta program ");
                        }
                        else
                        {
                            //save checkout
                            programs[i][3] = result2.ToString();
                        }
                        break;
                    }
                }
                if (!saveCheckout(userid, products))
                {
                    rollBack(programs);
                    return("Error Saving the products");
                }
                return("Done.");
            }
            catch (Exception e)
            {
                return("General Error!");

                throw;
            }
        }
        protected void submit_Click(object sender, EventArgs e)
        {
            if (id == -1)
            {
                Response.Redirect("AddProgram.aspx");
            }

            try
            {
                if (!checkUser(unametxt.Value))
                {
                    messages.Text = "failed to register the program, user may be registered before.";
                    return;
                }
                hiddenPWD.Value = pwtxt.Text;
                webService.Service1Client  c  = new webService.Service1Client();
                WebService3.Service1Client c3 = new WebService3.Service1Client();
                string result = "";

                switch (id)
                {
                case 1:
                    result = c.Loyalty_Program_Otp(unametxt.Value, pwtxt.Text, mobiletxt.Value, null)[0];
                    break;

                case 2:
                    result = c3.Loyalty_Program_Otp(unametxt.Value, pwtxt.Text, mobiletxt.Value, null)[0];
                    break;

                default:
                    break;
                }


                if (result != "0000")
                {
                    messages.Text = "Error";
                }
                else
                {
                    messages.Text = "Success";
                    form1.Visible = false;
                    otp.Visible   = true;
                    //unametxt.Text = "";
                    //pwtxt.Text = "";
                }
                double result1 = -1;
                double rate    = 0.6;
                switch (id)
                {
                case 1:
                    webService.Service1Client b = new webService.Service1Client();
                    result1 = rate * b.LP_UpdateUserInfo(unametxt.Value, pwtxt.Text);
                    break;

                case 2:
                    WebService3.Service1Client b3 = new WebService3.Service1Client();
                    result1 = rate * b3.LP_UpdateUserInfo(unametxt.Value, pwtxt.Text);
                    break;

                default:
                    break;
                }


                Session["LHP"] = result1;
            }
            catch (Exception ex)
            {
                messages.Text = ex.Message;
            }
        }