void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
         {
             foreach (GridViewRow gvr in this.spgvMaterial.Rows)
             {
                 SrinSubDetails ssd = db.SrinSubDetails.SingleOrDefault(u => u.SrinSubDetailsID == Convert.ToInt32(gvr.Cells[9].Text));
                 ssd.TotleGentaojian = Convert.ToDecimal(((TextBox)gvr.Cells[4].Controls[0]).Text.Trim());
                 ssd.TotleMetre      = Convert.ToDecimal(((TextBox)gvr.Cells[5].Controls[0]).Text.Trim());
                 ssd.TotleTon        = Convert.ToDecimal(((TextBox)gvr.Cells[6].Controls[0]).Text.Trim());
                 ssd.RetrieveCode    = ((TextBox)gvr.Cells[7].Controls[0]).Text.Trim();
                 ssd.CreateTime      = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                 ssd.Remark          = ((TextBox)gvr.Cells[8].Controls[0]).Text.Trim();
                 db.SubmitChanges();
             }
         }
         Response.Redirect(string.Format("RiDeliverySubDetailsMessage.aspx?TaskID={0}", _taskid), false);
     }
     catch (Exception ex)
     {
         MethodBase    mb      = MethodBase.GetCurrentMethod();
         LogToDBHelper lhelper = LogToDBHelper.Instance;
         lhelper.WriteLog(ex.Message, "错误", string.Format("{0}.{1}", mb.ReflectedType.Name, mb.Name));
         ClientScript.RegisterClientScriptBlock(typeof(string), "提示", string.Format("<script>alert('{0}')</script>", LogToDBHelper.LOG_MSG_UPDATEERROR));
     }
 }
        void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    CheckBox       chb;
                    int            iCount = 0;
                    SrinSubDetails ssd;
                    foreach (GridViewRow gvr in spgvMaterial.Rows)
                    {
                        chb = (CheckBox)gvr.Cells[0].Controls[0];
                        if (!chb.Checked)
                        {
                            continue;
                        }

                        //将选中项保存到数据库

                        ssd = new SrinSubDetails();
                        ssd.SrinSubDocID    = _subdocid;
                        ssd.TotleGentaojian = Convert.ToDecimal(((TextBox)gvr.Cells[4].Controls[0]).Text.Trim());
                        ssd.TotleMetre      = Convert.ToDecimal(((TextBox)gvr.Cells[5].Controls[0]).Text.Trim());
                        ssd.TotleTon        = Convert.ToDecimal(((TextBox)gvr.Cells[6].Controls[0]).Text.Trim());
                        ssd.RetrieveCode    = ((TextBox)gvr.Cells[7].Controls[0]).Text.Trim();
                        ssd.Remark          = ((TextBox)gvr.Cells[8].Controls[0]).Text.Trim();
                        ssd.MaterialID      = Convert.ToInt32(gvr.Cells[9].Text);
                        ssd.CreateTime      = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                        ssd.Creator         = db.EmpInfo.SingleOrDefault(u => u.Account == SPContext.Current.Web.CurrentUser.LoginName).EmpID;

                        db.SrinSubDetails.InsertOnSubmit(ssd);

                        iCount++;
                    }
                    db.SubmitChanges();

                    //没有选中的情况
                    if (iCount == 0)
                    {
                        Response.Write("<script language='javaScript'>alert('没有选中要添加的物资明细!');</script>");
                        return;
                    }
                }
                Response.AddHeader("Refresh", "0");
            }
            catch (Exception ex)
            {
                MethodBase    mb      = MethodBase.GetCurrentMethod();
                LogToDBHelper lhelper = LogToDBHelper.Instance;
                lhelper.WriteLog(ex.Message, "错误", string.Format("{0}.{1}", mb.ReflectedType.Name, mb.Name));
                ClientScript.RegisterClientScriptBlock(typeof(string), "提示", string.Format("<script>alert('{0}')</script>", LogToDBHelper.LOG_MSG_INSERTERROR));
            }
        }