public List <CrushedMaterialDetail> getAllCrushedMaterial(string area, string status)
        {
            List <CrushedMaterialDetail> cList = new List <CrushedMaterialDetail>();
            SelectCommandBuilder         s     = new SelectCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "trymolde");
            string        sql = "SELECT id, 品番, 材料, 材料编号, 模具担当, addtime, area1style, area2style, area3style, area4style FROM trymolde WHERE (PO处理 = '粉碎') AND (isApprove = 'OK') AND (area" + area + "style = '" + status + "') ORDER BY addtime";
            SqlDataReader dr  = s.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    CrushedMaterialDetail c = new CrushedMaterialDetail()
                    {
                        id         = dr.GetInt32(0),
                        Name       = dr.GetString(1),
                        Material   = dr.GetString(2),
                        MaterialNo = dr.GetString(3),
                        JigLeader  = dr.GetString(4),
                        addtime    = dr.GetString(5),
                        area1style = dr.IsDBNull(6) ? "待粉碎" : getStatusdeng(dr.GetString(6)),
                        area2style = dr.IsDBNull(7) ? "待粉碎" : getStatusdeng(dr.GetString(7)),
                        area3style = dr.IsDBNull(8) ? "待粉碎" : getStatusdeng(dr.GetString(8)),
                        area4style = dr.IsDBNull(9) ? "待粉碎" : getStatusdeng(dr.GetString(9))
                    };
                    cList.Add(c);
                }
            }
            return(cList);
        }
        protected void btnDone_Click(object sender, EventArgs e)
        {
            if (ddlDemp.SelectedItem.Value == "0")
            {
                Response.Write("<script>alert('请选择处理区域!')</script>");
                return;
            }
            else
            {
                ViewState["area"] = ddlDemp.SelectedItem.Value;
            }
            List <CrushedMaterialDetail> cmList = new List <CrushedMaterialDetail>();
            List <string> sqlList = new List <string>();

            if (dgvList.Rows.Count != 0)
            {
                for (int i = 0; i < dgvList.Rows.Count; i++)
                {
                    if ((dgvList.Rows[i].Cells[0].FindControl("cboCheckItem") as CheckBox).Checked == true)
                    {
                        CrushedMaterialDetail c = new CrushedMaterialDetail()
                        {
                            id         = int.Parse((dgvList.Rows[i].Cells[0].FindControl("Hfid") as HiddenField).Value),
                            Name       = (dgvList.Rows[i].Cells[1].FindControl("Label1") as Label).Text,
                            MaterialNo = (dgvList.Rows[i].Cells[2].FindControl("Label2") as Label).Text,
                            Material   = (dgvList.Rows[i].Cells[3].FindControl("Label3") as Label).Text,
                            JigLeader  = (dgvList.Rows[i].Cells[4].FindControl("Label4") as Label).Text,
                            addtime    = (dgvList.Rows[i].Cells[5].FindControl("Label5") as Label).Text,
                            area1style = (dgvList.Rows[i].Cells[6].FindControl("Label6") as Label).Text,
                            area2style = (dgvList.Rows[i].Cells[7].FindControl("Label7") as Label).Text,
                            area3style = (dgvList.Rows[i].Cells[8].FindControl("Label8") as Label).Text,
                            area4style = (dgvList.Rows[i].Cells[9].FindControl("Label9") as Label).Text,
                            Qty        = int.Parse((dgvList.Rows[i].Cells[10].FindControl("TextBox1") as TextBox).Text == string.Empty ? "0" : (dgvList.Rows[i].Cells[10].FindControl("TextBox1") as TextBox).Text)
                        };
                        cmList.Add(c);
                    }
                }
                if (cmList.Count == 0)
                {
                    Response.Write("<script>alert('没有选择任何行!')</script>");
                    return;
                }
                for (int i = 0; i < cmList.Count; i++)
                {
                    UpdateCommandBuilder up = new UpdateCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "trymolde");
                    string status           = "";
                    switch (ViewState["area"].ToString())
                    {
                    case "1":
                        up.UpdateColumn("area1style", "Done(" + cmList[i].Qty + ")");
                        up.UpdateColumn("area1CrushedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        status = cmList[i].area1style;
                        break;

                    case "2":
                        up.UpdateColumn("area2style", "Done(" + cmList[i].Qty + ")");
                        up.UpdateColumn("area2CrushedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        status = cmList[i].area2style;
                        break;

                    case "3":
                        up.UpdateColumn("area3style", "Done(" + cmList[i].Qty + ")");
                        up.UpdateColumn("area3CrushedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        status = cmList[i].area3style;
                        break;

                    case "4":
                        up.UpdateColumn("area4style", "Done(" + cmList[i].Qty + ")");
                        up.UpdateColumn("area4CrushedDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        status = cmList[i].area4style;
                        break;

                    default:
                        break;
                    }
                    up.ConditionsColumn("id", cmList[i].id);
                    sqlList.Add(up.getUpdateCommand());
                    if (status != "粉碎中")
                    {
                        Response.Write("<script>alert('选择行中数据有误,请选择<粉碎中>的部番!')</script>");
                        return;
                    }
                }
                InsertCommandBuilder ins = new InsertCommandBuilder(ConnectionFactory.ConnectionString_hudsonwwwroot, "trymolde");
                int count = ins.ExcutTransaction(sqlList);
                if (count != 0)
                {
                    dgvList.DataSource = getAllCrushedMaterial();
                    dgvList.DataBind();
                }
            }
        }