private void InsertAudited(GridViewRow gvr)
        {
            try
            {
                using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    Label lb = (Label)gvr.Cells[23].Controls[0];



                    //新增

                    StorageInAudited sia = new StorageInAudited();
                    sia.StorageInID        = _storageinid;
                    sia.MaterialID         = (db.MaterialInfo.SingleOrDefault(u => u.MaterialID == Convert.ToInt32(gvr.Cells[25].Text))).MaterialID;
                    sia.SpecificationModel = gvr.Cells[4].Text;


                    sia.QuantityGentaojian = Convert.ToDecimal(gvr.Cells[5].Text);
                    sia.QuantityMetre      = Convert.ToDecimal(gvr.Cells[6].Text);
                    sia.QuantityTon        = Convert.ToDecimal(gvr.Cells[7].Text);
                    sia.Quantity           = Convert.ToDecimal(gvr.Cells[8].Text);
                    sia.CurUnit            = gvr.Cells[9].Text;

                    sia.NumberQualified     = 0;
                    sia.InspectionTime      = Convert.ToDateTime(gvr.Cells[10].Text);
                    sia.InspectionReportNum = gvr.Cells[11].Text;
                    sia.UnitPrice           = Convert.ToDecimal(gvr.Cells[12].Text);
                    sia.Amount      = Convert.ToDecimal(gvr.Cells[13].Text);
                    sia.PileID      = (db.PileInfo.SingleOrDefault(u => u.PileCode == gvr.Cells[15].Text)).PileID;
                    sia.financeCode = gvr.Cells[16].Text;
                    sia.StorageTime = Convert.ToDateTime(gvr.Cells[17].Text);
                    sia.BatchIndex  = gvr.Cells[18].Text;

                    var SevTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                    sia.AuditTime = SevTime.First();
                    sia.Remark    = gvr.Cells[22].Text;

                    sia.SupplierID       = Convert.ToInt32(gvr.Cells[26].Text);
                    sia.MaterialsManager = Convert.ToInt32(gvr.Cells[27].Text);
                    sia.WarehouseWorker  = Convert.ToInt32(gvr.Cells[28].Text);

                    sia.AuditStatus        = lb.Text == "未通过" ? "未通过" : "已通过";
                    sia.MaterialAccounting = (db.EmpInfo.SingleOrDefault(u => u.EmpName == SPContext.Current.Web.CurrentUser.Name)).EmpID;

                    db.StorageInAudited.InsertOnSubmit(sia);



                    db.SubmitChanges();
                }
            }
            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));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 发回重新质检
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnReCheck_Click(object sender, EventArgs e)
        {
            try
            {
                using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    //从审核表中删除此批次记录,之前写过库
                    var siaTemp = from a in db.StorageInAudited
                                  where a.StorageInID == _storageinid && a.BatchIndex == _batchname
                                  select new { a.StorageInAuditedID };
                    for (int i = 0; i < siaTemp.ToList().Count; i++)
                    {
                        StorageInAudited sia = db.StorageInAudited.SingleOrDefault(a => a.StorageInAuditedID == siaTemp.ToList()[i].StorageInAuditedID);
                        if (sia != null)
                        {
                            db.StorageInAudited.DeleteOnSubmit(sia);
                        }
                    }
                    db.SubmitChanges();


                    //任务信息
                    TaskStorageIn tsi = db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID == _taskstorageid);
                    tsi.TaskState    = "已完成";
                    tsi.InspectState = "已审核";
                    StorageIn si = db.StorageIn.SingleOrDefault(u => u.StorageInID == tsi.StorageInID);
                    //发送新任务(回退任务)
                    TaskStorageIn TSI = new TaskStorageIn();

                    TSI.TaskCreaterID = reEmpId(SPContext.Current.Web.CurrentUser.LoginName);
                    TSI.TaskTargetID  = tsi.TaskCreaterID;
                    if (TSI.TaskTargetID == 0)
                    {
                        ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('不存在质检用户,请同步AD账户 ')</script>");
                        return;
                    }

                    TSI.StorageInID   = _storageinid;
                    TSI.StorageInType = "正常入库";
                    TSI.TaskTitle     = "材料会计审核任务:" + tsi.TaskTitle.ToString() + "(未通过)";
                    TSI.TaskState     = "未完成";
                    TSI.TaskDispose   = "未废弃";
                    TSI.TaskType      = "质检";
                    TSI.InspectState  = "驳回";

                    //TSI.BatchOfIndex = this.ddlbatch.SelectedItem.Text.ToString();

                    TSI.QCBatch = tsi.QCBatch;


                    TSI.Remark = "交货通知单编号为:" + si.StorageInCode + "的" + tsi.QCBatch.ToString() + "物资审核不合格原因:" + this.txtOpinion.Text.Trim();
                    var SevTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                    TSI.CreateTime = SevTime.First();
                    db.TaskStorageIn.InsertOnSubmit(TSI);
                    db.SubmitChanges();
                    Response.Redirect("../../default-old.aspx", 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_INSERTERROR));
            }
        }