Пример #1
0
    public Model.tab_orders doshop_eticket(Model.tab_orders orders)
    {
        Model.tab_eticket  Modeticket;
        Model.tab_products product = new Model.tab_products();

        string items = orders.ReportContent;

        string[]      ts = items.Split(';');
        StringBuilder sb = new StringBuilder();
        string        s;
        int           index;

        for (int i = 0; i < ts.Length; i++)
        {
            sb.Append(ts[i]);
            index = ts[i].IndexOf('*');
            s     = ts[i].Substring(0, index);

            product.productID = int.Parse(s);
            product           = pb.getproducts(product);

            if (product.uplimit == "电子码")
            {
                string eticket = mketicket("MP" + s, product.productID * 10 + i);

                Modeticket              = new Model.tab_eticket();
                Modeticket.orderID      = orders.orderID;
                Modeticket.customerName = orders.customerName;
                Modeticket.productName  = product.productName;
                Modeticket.productID    = product.productID;
                Modeticket.itemnum      = ts[i].Substring(index + 1);
                Modeticket.eticket      = eticket;
                Modeticket.time         = DateTime.Now;
                eb.Add(Modeticket);

                sb.Append("|" + eticket);
            }
            sb.Append(";");
        }
        sb.Remove(sb.Length - 1, 1);

        orders.ReportContent = sb.ToString();
        return(orders);
    }
Пример #2
0
 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "con")
     {
         Label la    = (Label)e.Item.FindControl("Label1");
         int   proID = Convert.ToInt32(la.Text);
         Response.Redirect("product_update.aspx?proID=" + proID);
     }
     else if (e.CommandName == "down")
     {
         int pid = int.Parse(e.CommandArgument.ToString());
         for (int i = 0; i < this.Repeater1.Items.Count - 1; i++)
         {
             Label      label2a      = (Label)Repeater1.Items[i].FindControl("Label2");
             Label      label2b      = (Label)Repeater1.Items[i + 1].FindControl("Label2");
             string     temp         = "";
             LinkButton LinkButton2a = (LinkButton)Repeater1.Items[i].FindControl("LinkButton2");
             LinkButton LinkButton2b = (LinkButton)Repeater1.Items[i + 1].FindControl("LinkButton2");
             if (LinkButton2a.CommandArgument.ToString() == e.CommandArgument.ToString())
             {
                 //交换px
                 temp         = label2a.Text;
                 label2a.Text = label2b.Text;
                 label2b.Text = temp;
                 //更新本条目录的px
                 product.productID = pid;
                 product           = B_pro.getproducts(product);
                 product.px        = int.Parse(label2a.Text);
                 B_pro.update(product);
                 //更新下一条目录的px
                 product.productID = int.Parse(LinkButton2b.CommandArgument.ToString());;
                 product           = B_pro.getproducts(product);
                 product.px        = int.Parse(label2b.Text);
                 B_pro.update(product);
             }
         }
         repeaterBind();
     }
     else if (e.CommandName == "up")
     {
         int pid = int.Parse(e.CommandArgument.ToString());
         for (int i = 1; i < this.Repeater1.Items.Count; i++)
         {
             Label      label2a       = (Label)Repeater1.Items[i].FindControl("Label2");
             Label      label2b       = (Label)Repeater1.Items[i - 1].FindControl("Label2");
             string     temp          = "";
             LinkButton ImageButton3a = (LinkButton)Repeater1.Items[i].FindControl("LinkButton3");
             LinkButton ImageButton3b = (LinkButton)Repeater1.Items[i - 1].FindControl("LinkButton3");
             if (ImageButton3a.CommandArgument.ToString() == e.CommandArgument.ToString())
             {
                 //交换px
                 temp         = label2a.Text;
                 label2a.Text = label2b.Text;
                 label2b.Text = temp;
                 //更新本条目录的px
                 product.productID = pid;
                 product           = B_pro.getproducts(product);
                 product.px        = int.Parse(label2a.Text);
                 B_pro.update(product);
                 //更新下一条目录的px
                 product.productID = int.Parse(ImageButton3b.CommandArgument.ToString());;
                 product           = B_pro.getproducts(product);
                 product.px        = int.Parse(label2b.Text);
                 B_pro.update(product);
             }
         }
         repeaterBind();
     }
 }
    protected void Button5_Click1(object sender, EventArgs e)
    {
        int successfulcount = 0, errorcount = 0;

        try
        {
            if (this.FileUpload1.HasFile)
            {
                if (!ue.SaveUpFile("~/Admin/temp/", this.FileUpload1))//上传文件
                {
                    throw new Exception("上传文件失败!");
                }

                DataTable inputdt = ue.InputExcel("Sheet1");
                if (inputdt == null)
                {
                    throw new Exception("Excel文件读取失败!");
                }

                int j;

                for (int i = 0; i < inputdt.Rows.Count; i++)
                {
                    j                           = 0;
                    products                    = new Model.tab_products();
                    products.productName        = inputdt.Rows[i][j++].ToString().Trim();
                    products.productClassID     = int.Parse(inputdt.Rows[i][j++].ToString());
                    products.ikangName          = inputdt.Rows[i][j++].ToString().Trim();
                    products.ikangID            = inputdt.Rows[i][j++].ToString().Trim();
                    products.meinianName        = inputdt.Rows[i][j++].ToString().Trim();
                    products.meinianID          = inputdt.Rows[i][j++].ToString().Trim();
                    products.cimingNmae         = inputdt.Rows[i][j++].ToString().Trim();
                    products.cimingID           = inputdt.Rows[i][j++].ToString().Trim();
                    products.ex1Name            = inputdt.Rows[i][j++].ToString().Trim();
                    products.ex1ID              = inputdt.Rows[i][j++].ToString().Trim();
                    products.type               = inputdt.Rows[i][j++].ToString().Trim();
                    products.unit               = inputdt.Rows[i][j++].ToString().Trim();
                    products.uplimit            = inputdt.Rows[i][j++].ToString().Trim();
                    products.downlimit          = inputdt.Rows[i][j++].ToString().Trim();
                    products.productUnitPrice   = inputdt.Rows[i][j++].ToString() == ""?0:double.Parse(inputdt.Rows[i][j++].ToString());
                    products.productMarketPrice = inputdt.Rows[i][j++].ToString() == ""?0: double.Parse(inputdt.Rows[i][j++].ToString());


                    try
                    {
                        if (bp.AddPro(products) < 1)
                        {
                            errorcount++;
                        }
                        else
                        {
                            successfulcount++;
                        }
                    }
                    catch
                    {
                        errorcount++;
                    }
                }
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "message", " <script>alert('操作已完成!其中成功导入数据" + successfulcount + "条,失败" + errorcount + "条'); </script>");
                GridView1.DataBind();
            }
            else
            {
                throw new Exception("请选择Excel文件!");
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "message", " <script>alert('" + ex.Message + "'); </script>");
        }
    }