예제 #1
0
    protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
    {
        decimal id_user;
        string  user_name;

        if (Request.Cookies["Login_User"] == null)
        {
            Label30.Visible = true;
            Login1.Visible  = true;
            TextTitle.Focus();
        }
        else
        {
            Label30.Visible = false;
            id_user         = decimal.Parse(Request.Cookies["Id_User"].Value);
            user_name       = Request.Cookies["Family_User"].Value;

            user      ac = new user();
            userDatum dm = new userDatum();
            dm.Id = id_user;
            DataTable dt = ac.select_one_user(dm);
            user_name = dt.Rows[0]["name"].ToString() + " " + dt.Rows[0]["family"].ToString();



            //-----------------------------------------------------------------------------------------------//
            Shoping      ac2 = new Shoping();
            ShopingDatum dm2 = new ShopingDatum();

            PublicClass pc = new PublicClass();

            dm2.Id_User       = id_user;
            dm2.Register_Date = pc.GetDate();
            Random rnd    = new Random();
            string f_code = null;
            for (int j = 0; j < 16; j++)
            {
                f_code = f_code + rnd.Next(0, 9).ToString();
            }
            dm2.Factor_Code      = f_code;
            dm2.Tasx             = decimal.Parse(Label33.Text);
            dm2.Send_Price       = decimal.Parse(Label19.Text);
            dm2.Sum_Price        = decimal.Parse(Label22.Text);
            dm2.Factor_Condition = "در تاریخ " + pc.GetDate() + " سفارش ثبت شد";
            dm2.Customer_Name    = user_name;

            decimal id_factor = ac2.Insert_Factor(dm2);

            dm2.Id_Factor = id_factor;

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                dm2.Count      = int.Parse(((DropDownList)(GridView1.Rows[i].FindControl("DropDownList1"))).SelectedValue);
                dm2.Id_Product = decimal.Parse(((Label)(GridView1.Rows[i].FindControl("lblid"))).Text);

                ac2.Insert_Factor_Details(dm2);
                update_number_shop(decimal.Parse(((Label)(GridView1.Rows[i].FindControl("lblid"))).Text), int.Parse(((DropDownList)(GridView1.Rows[i].FindControl("DropDownList1"))).SelectedValue));
            }
            Session["ProductTable"] = null;
            Response.Redirect("~/index.aspx?Type=ShopPeymentRegister&Factor_Code=" + f_code + "&Id_Factor=" + id_factor + "&Sum_Price=" + decimal.Parse(Label22.Text));
        }
    }