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



                    //新增

                    CommitInAudited sia = new CommitInAudited();
                    sia.CommitInID         = _storageinid;
                    sia.MaterialID         = (db.MaterialInfo.SingleOrDefault(u => u.MaterialCode == gvr.Cells[3].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[15].Text;

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

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

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

                    db.CommitInAudited.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));
            }
        }
Example #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.CommitInAudited
                                  where a.CommitInID == _storageinid
                                  select new { a.CommitInAuditedID };
                    for (int i = 0; i < siaTemp.ToList().Count; i++)
                    {
                        CommitInAudited sia = db.CommitInAudited.SingleOrDefault(a => a.CommitInAuditedID == siaTemp.ToList()[i].CommitInAuditedID);
                        if (sia != null)
                        {
                            db.CommitInAudited.DeleteOnSubmit(sia);
                        }
                    }
                    db.SubmitChanges();


                    //任务信息
                    TaskStorageIn tsi = db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID == _taskstorageid);
                    tsi.TaskState    = "已完成";
                    tsi.InspectState = "已审核";
                    CommitIn si = db.CommitIn.SingleOrDefault(u => u.CommitInID == 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.StorageInType;
                    TSI.TaskTitle     = "材料会计审核任务:" + tsi.TaskTitle.ToString() + "(未通过)";
                    TSI.TaskState     = "未完成";
                    TSI.TaskDispose   = "未废弃";
                    TSI.TaskType      = "质检";
                    TSI.InspectState  = "驳回";

                    TSI.QCBatch = tsi.QCBatch;


                    TSI.Remark = "交货通知单编号为:" + si.CommitInCode + "的物资审核不合格原因:" + 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));
            }
        }