예제 #1
0
파일: Add.aspx.cs 프로젝트: vonchengk/MQC
        protected void CreateBatch_Click(object sender, EventArgs e)
        {
            Maktx = TbMaktx.Value.Trim().ToUpper();
            Mold  = TbMold.Value.Trim().ToUpper();
            bool       run         = true;
            List <Add> productlist = new List <Add>();
            List <Add> cavitylist  = new List <Add>();
            List <Add> checklist   = new List <Add>();

            run = IsNoRun(Maktx, out productlist, out cavitylist, out checklist);
            if (run == true)
            {
                using (DbAppDataContext db = new DbAppDataContext())
                {
                    var maxId = db.Record.Max(c => c.Id);
                    maxId += 1;
                    Record data = new Record();
                    data.Maktx    = Maktx;
                    data.Mold     = Mold;
                    data.Customer = productlist[0].Customer;
                    data.Standard = productlist[0].Standard;
                    string   date = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
                    string[] strs = { Mold, Maktx, date, maxId.ToString() };
                    data.Batch      = string.Join("_", strs);
                    data.CreateDate = DateTime.Now;
                    db.Record.InsertOnSubmit(data);
                    db.SubmitChanges();

                    string[] serial = cavitylist[0].SerialNo.Split('|');
                    for (int i = 0; i < cavitylist[0].Num; i++)
                    {
                        for (int j = 0; j < checklist.Count; j++)
                        {
                            Record_Cavity dataCavity = new Record_Cavity();
                            dataCavity.Batch    = string.Join("_", strs);
                            dataCavity.CavityNo = serial[i];
                            dataCavity.No       = checklist[j].No;
                            dataCavity.Type     = checklist[j].Type;
                            dataCavity.Content  = checklist[j].Content;
                            dataCavity.Tool     = checklist[j].Tool;
                            dataCavity.L_Limit  = checklist[j].L_Limit2;
                            dataCavity.U_Limit  = checklist[j].U_Limit2;
                            db.Record_Cavity.InsertOnSubmit(dataCavity);
                            db.SubmitChanges();
                        }
                    }
                    Response.Write("<script>alert('成功')</script>");//创建成功
                }
            }
        }
예제 #2
0
파일: Add.aspx.cs 프로젝트: vonchengk/MQC
        protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string strResult = "";
            int    id        = (int)GridView2.DataKeys[e.RowIndex].Value;

            CavityNo = ((Label)GridView2.Rows[e.RowIndex].FindControl("Label1")).Text.ToString();
            bool run = true;

            using (DbAppDataContext db = new DbAppDataContext())
            {
                Record_Cavity data = db.Record_Cavity.SingleOrDefault(c => c.Id == id);
                if (data.Type == "计量")
                {
                    strResult = ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TbResult")).Text.ToString();
                }
                else
                {
                    strResult = ((DropDownList)GridView2.Rows[e.RowIndex].FindControl("DdlResult")).Text;
                }

                if (run)
                {
                    data.Result = strResult;
                    db.SubmitChanges();
                    var temp = from m in db.Record_Cavity
                               where m.Batch == Batch && m.CavityNo == CavityNo
                               select m;
                    foreach (var item in temp)
                    {
                        if (item.Result.Length > 0)
                        {
                            foreach (var item2 in temp)
                            {
                                item2.Stamp = "已编辑";
                            }
                            db.SubmitChanges();
                            break;
                        }
                    }
                    GridView2.EditIndex = -1;
                    BindCheck(data.CavityNo);
                    BindCavity();
                }
            }
        }