Example #1
0
        //保存数据到线下库
        private TableOfStocks StorageToOffLine(GridViewRow gvr)
        {
            TableOfStocks tos = new TableOfStocks();

            tos.StorageInType      = "回收入库";
            tos.BatchIndex         = "N/A";
            tos.MaterialCode       = gvr.Cells[4].Text;
            tos.QuantityGentaojian = Convert.ToDecimal(gvr.Cells[8].Text);
            tos.QuantityMetre      = Convert.ToDecimal(gvr.Cells[9].Text);
            tos.QuantityTon        = Convert.ToDecimal(gvr.Cells[10].Text);
            tos.UnitPrice          = Convert.ToDecimal(gvr.Cells[11].Text);
            tos.CurUnit            = gvr.Cells[12].Text;
            tos.Amount             = tos.UnitPrice * Convert.ToDecimal(gvr.Cells[GetPricingIndex(tos.CurUnit)].Text);
            tos.StorageTime        = Convert.ToDateTime(gvr.Cells[13].Text);
            tos.Remark             = (gvr.Cells[15].Controls[0] as TextBox).Text.Trim();
            tos.ExpectedProject    = projectid;
            tos.StorageID          = Convert.ToInt32(gvr.Cells[17].Text);
            tos.PileID             = Convert.ToInt32(gvr.Cells[18].Text);
            tos.ManufacturerID     = Convert.ToInt32(gvr.Cells[19].Text);
            tos.MaterialID         = Convert.ToInt32(gvr.Cells[20].Text);
            return(tos);
        }
        void btnko_Click(object sender, EventArgs e)
        {
            try
            {
                using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    var tp = from a in db.CommitDirector
                             where a.CommitInHead.CommitInAssets.CommitInTest.CommitInMaterialsLeader.CommitInMaterials.CommitProduce.StorageInID == Convert.ToInt32(Request.QueryString["StorageInID"]) && a.CommitInHead.CommitInAssets.CommitInTest.CommitInMaterialsLeader.CommitInMaterials.CommitProduce.BatchIndex == Request.QueryString["QCBatch"].ToString()
                             select a;
                    if (tp.ToArray().Length > 0)
                    {
                        ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('不能重复插入记录! ')</script>");
                        return;
                    }


                    if (this.checkPass.Checked)
                    {
                        for (int i = 0; i < this.gv.Rows.Count; i++)
                        {
                            CommitDirector sih = new CommitDirector();
                            sih.HeadID  = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 1].Text.ToString());
                            sih.Approve = "是";
                            var SevTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                            sih.CreateTime = SevTime.First();
                            sih.Creator    = reEmpId(SPContext.Current.Web.CurrentUser.LoginName);
                            db.CommitDirector.InsertOnSubmit(sih);
                            db.SubmitChanges();


                            //写入线下数据库
                            TableOfStocks tos = new TableOfStocks();
                            tos.StorageInID        = Convert.ToInt32(Request.QueryString["StorageInID"]);
                            tos.StorageInType      = "委外入库";
                            tos.MaterialID         = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 4].Text.ToString());
                            tos.MaterialCode       = "N/A";
                            tos.QuantityGentaojian = Convert.ToDecimal(this.gv.Rows[i].Cells[4].Text.ToString());
                            tos.QuantityMetre      = Convert.ToDecimal(this.gv.Rows[i].Cells[5].Text.ToString());
                            tos.QuantityTon        = Convert.ToDecimal(this.gv.Rows[i].Cells[6].Text.ToString());
                            tos.CurUnit            = this.gv.Rows[i].Cells[7].Text.ToString();
                            tos.UnitPrice          = Convert.ToDecimal(this.gv.Rows[i].Cells[8].Text.ToString());
                            tos.Amount             = Convert.ToDecimal(this.gv.Rows[i].Cells[9].Text.ToString());
                            tos.ExpectedProject    = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 5].Text.ToString());
                            tos.Remark             = this.gv.Rows[i].Cells[12].Text.ToString();
                            tos.BatchIndex         = _QCbatch;
                            tos.ManufacturerID     = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 3].Text.ToString());
                            tos.SupplierID         = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 2].Text.ToString());
                            tos.PileID             = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 6].Text.ToString());
                            tos.StorageID          = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 9].Text.ToString());
                            tos.MaterialsManager   = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 7].Text.ToString());
                            tos.AssetsManager      = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 8].Text.ToString());


                            tos.ReceivingTypeName = this.gv.Rows[i].Cells[this.gv.Columns.Count - 12].Text.ToString();
                            tos.StorageInCode     = this.gv.Rows[i].Cells[this.gv.Columns.Count - 11].Text.ToString();
                            tos.BillCode          = this.gv.Rows[i].Cells[this.gv.Columns.Count - 10].Text.ToString();

                            tos.StorageTime = Convert.ToDateTime(this.gv.Rows[i].Cells[14].Text.ToString());
                            var Time = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                            tos.CreateTime = Time.First();
                            tos.Creator    = reEmpId(SPContext.Current.Web.CurrentUser.LoginName);

                            db.TableOfStocks.InsertOnSubmit(tos);
                            db.SubmitChanges();

                            //修改人物完成状态
                            TaskStorageIn tsi = db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID == _taskID);
                            tsi.TaskState = "已完成";
                            db.SubmitChanges();
                        }
                        btnko.Enabled     = false;
                        checkPass.Enabled = false;
                    }
                    else
                    {
                        //审核不通过,回退操作

                        //删除写入的数据
                        var temp = from a in db.CommitDirector
                                   where a.CommitInHead.CommitInAssets.CommitInTest.CommitInMaterialsLeader.CommitInMaterials.CommitProduce.StorageInID == Convert.ToInt32(Request.QueryString["StorageInID"]) && a.CommitInHead.CommitInAssets.CommitInTest.CommitInMaterialsLeader.CommitInMaterials.CommitProduce.BatchIndex == Request.QueryString["QCBatch"].ToString()
                                   select new { a.StorageInDirectorID };
                        var li = temp.ToList();

                        for (int i = 0; i < li.Count; i++)
                        {
                            CommitDirector sd = db.CommitDirector.SingleOrDefault(u => u.StorageInDirectorID == li[i].StorageInDirectorID);
                            if (sd != null)
                            {
                                db.CommitDirector.DeleteOnSubmit(sd);
                                db.SubmitChanges();
                            }
                        }

                        //回发任务
                        //原任务
                        TaskStorageIn tsi = db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID == _taskID);
                        tsi.TaskState    = "已完成";
                        tsi.InspectState = "已审核";


                        //新任务
                        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   = Convert.ToInt32(Request.QueryString["StorageInID"]);
                        TSI.StorageInType = "委外入库";
                        TSI.TaskTitle     = tsi.TaskTitle + "(主任审批未通过)";
                        TSI.TaskState     = "未完成";
                        TSI.TaskDispose   = "未废弃";
                        TSI.TaskType      = "资产组长";
                        TSI.InspectState  = "驳回";

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

                        TSI.QCBatch = _QCbatch;


                        TSI.Remark = "审核未通过";
                        var Sev = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                        TSI.CreateTime = Sev.First();

                        db.TaskStorageIn.InsertOnSubmit(TSI);
                        db.SubmitChanges();
                        Response.Redirect("../../default-old.aspx", false);
                    }
                    //存库标识
                    ViewState["Temp"] = flag = true;
                }
                //Response.Redirect("QualifiedManage.aspx?StorageInID=" + Request.QueryString["StorageInID"] + "&&TaskStorageID=" + Request.QueryString["TaskStorageID"] + "&&QCBatch=" + Request.QueryString["QCBatch"] + " ");
            }
            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 #3
0
        void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //将审核结果保存到数据库
                using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    if (this.chbAgree.Checked)
                    {
                        //通過
                        //验证是否都有内容
                        _taskid = Convert.ToInt32(Request.QueryString["StockTransferTaskID"]);
                        StockTransferTask st = db.StockTransferTask.SingleOrDefault(a => a.StockTransferTaskID == _taskid);
                        bool   done          = false;
                        string strMessage    = "";
                        //修改所有数量
                        var std = db.StockTransferDetail.Where(a => a.StockTransferID == st.StockTransferID);
                        foreach (var n in std)
                        {
                            //获取原有库存对象
                            var ts = n.TableOfStocks;
                            //判断是否足够数量进行运算
                            //获取原有数
                            decimal dcmT  = 0;
                            decimal dcmT1 = 0;
                            decimal dcmT2 = 0;
                            decimal dcmT3 = 0;
                            decimal.TryParse(ts.QuantityGentaojian.ToString(), out dcmT);
                            decimal.TryParse(ts.QuantityMetre.ToString(), out dcmT1);
                            decimal.TryParse(ts.QuantityTon.ToString(), out dcmT2);
                            decimal.TryParse(ts.Quantity.ToString(), out dcmT3);
                            //获取移库数
                            //获取原有数
                            decimal dcmC  = 0;
                            decimal dcmC1 = 0;
                            decimal dcmC2 = 0;
                            decimal dcmC3 = 0;
                            decimal.TryParse(n.QuantityGentaojian.ToString(), out dcmC);
                            decimal.TryParse(n.QuantityMetre.ToString(), out dcmC1);
                            decimal.TryParse(n.QuantityTon.ToString(), out dcmC2);
                            decimal.TryParse(n.Quantity.ToString(), out dcmC3);
                            if (dcmT - dcmC >= 0 && dcmT1 - dcmC1 >= 0 && dcmT2 - dcmC2 >= 0 && dcmT3 - dcmC3 >= 0)
                            {
                                //插入
                                TableOfStocks tsNew = new TableOfStocks();
                                tsNew.CurUnit            = ts.CurUnit;
                                tsNew.financeCode        = ts.financeCode;
                                tsNew.MaterialID         = ts.MaterialID;
                                tsNew.MaterialsManager   = ts.MaterialsManager;
                                tsNew.NumberQualified    = ts.NumberQualified;
                                tsNew.PileID             = n.TargetPile;
                                tsNew.Quantity           = dcmC3;
                                tsNew.QuantityGentaojian = dcmC;
                                tsNew.QuantityMetre      = dcmC1;
                                tsNew.QuantityTon        = dcmC2;
                                tsNew.Remark             = ts.Remark;
                                tsNew.SpecificationModel = ts.SpecificationModel;
                                tsNew.StorageInID        = ts.StorageInID;
                                tsNew.StorageInType      = ts.StorageInType;
                                tsNew.StorageTime        = ts.StorageTime;
                                tsNew.SupplierID         = ts.SupplierID;
                                tsNew.UnitPrice          = ts.UnitPrice;
                                tsNew.WarehouseWorker    = ts.WarehouseWorker;
                                db.TableOfStocks.InsertOnSubmit(tsNew);
                                //减数
                                ts.Quantity           = dcmT3 - dcmC3;
                                ts.QuantityGentaojian = dcmT - dcmC;
                                ts.QuantityMetre      = dcmT1 - dcmC1;
                                ts.QuantityTon        = dcmT2 - dcmC2;
                                done = true;
                            }
                            else
                            {
                                strMessage += "移库失败!从" + ts.PileInfo.StorageInfo.StorageName + "|" + ts.PileInfo.PileName + "处移动到" + n.PileInfo.StorageInfo.StorageName + "|" + n.PileInfo.PileName + "失败!请检查数量是否足够!\br";
                                done        = false;
                                break;
                            }
                        }
                        if (done)
                        {
                            st.AcceptTime   = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                            st.AuditOpinion = this.txtOpinion.Text.Trim();
                            st.AuditStatus  = "审核通过";
                            st.TaskState    = "已完成";
                            //写入新的内容
                            db.SubmitChanges();
                        }
                        else
                        {
                            ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('" + strMessage + "')</script>");
                            Response.AddHeader("Refresh", "0");
                        }
                    }
                    else
                    {
                        //未通過
                        //通過
                        //验证是否都有内容
                        _taskid = Convert.ToInt32(Request.QueryString["StockTransferTaskID"]);
                        StockTransferTask st = db.StockTransferTask.SingleOrDefault(a => a.StockTransferTaskID == _taskid);
                        st.AcceptTime   = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                        st.AuditOpinion = this.txtOpinion.Text.Trim();
                        st.AuditStatus  = "审核未通过";
                        st.TaskState    = "已完成";
                        //写入新的内容
                        StockTransferTask st0 = db.StockTransferTask.Where(a => a.StockTransferID == st.StockTransferID).OrderBy(a => a.StockTransferTaskID).First();



                        StockTransferTask stt = new StockTransferTask();
                        stt.Remark          = this.txtOpinion.Text.Trim();
                        stt.StockTransferID = st.StockTransferID;
                        stt.TaskCreaterID   = st.TaskTargetID;
                        stt.TaskInType      = "移库任务";
                        stt.TaskState       = "未完成";
                        stt.TaskTargetID    = st0.TaskCreaterID;
                        stt.TaskTitle       = st.TaskTitle + "[材料会计审核未通过]";
                        stt.TaskType        = "发起人修改";
                        stt.CreateTime      = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                        db.StockTransferTask.InsertOnSubmit(stt);
                        db.SubmitChanges();
                        Response.Redirect("../../default-old.aspx", false);
                    }

                    //获取userid

                    // stNew.TaskTargetID = reEmpId(txtUser.Text.Trim());
                }
                // 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));
            }
        }
Example #4
0
        void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    var tp = from a in db.CommitInDirector
                             where a.CommitInID == Convert.ToInt32(Request.QueryString["StorageInID"])
                             select a;
                    if (tp.ToArray().Length > 0)
                    {
                        ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('不能重复插入记录!')</script>");
                        return;
                    }
                }


                if (chbAgree.Checked == true)
                {
                    using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                    {
                        for (int i = 0; i < this.gv.Rows.Count; i++)
                        {
                            //写入流程中的主任审核表
                            CommitInDirector sid = new CommitInDirector();

                            sid.CommitInID = Convert.ToInt32(Request.QueryString["StorageInID"]);

                            MaterialInfo mi = db.MaterialInfo.SingleOrDefault(u => u.MaterialCode == this.gv.Rows[i].Cells[2].Text.ToString());
                            sid.MaterialID         = mi.MaterialID;
                            sid.SpecificationModel = this.gv.Rows[i].Cells[3].Text.ToString();

                            sid.QuantityGentaojian = Convert.ToDecimal(this.gv.Rows[i].Cells[4].Text.ToString());
                            sid.QuantityMetre      = Convert.ToDecimal(this.gv.Rows[i].Cells[5].Text.ToString());
                            sid.QuantityTon        = Convert.ToDecimal(this.gv.Rows[i].Cells[6].Text.ToString());
                            sid.Quantity           = Convert.ToDecimal(this.gv.Rows[i].Cells[7].Text.ToString());
                            sid.CurUnit            = this.gv.Rows[i].Cells[8].Text.ToString();
                            sid.NumberQualified    = 0;

                            sid.InspectionReportNum = this.gv.Rows[i].Cells[12].Text.ToString();
                            sid.InspectionTime      = Convert.ToDateTime(this.gv.Rows[i].Cells[13].Text.ToString());
                            sid.UnitPrice           = Convert.ToDecimal(this.gv.Rows[i].Cells[9].Text.ToString());
                            sid.Amount = Convert.ToDecimal(this.gv.Rows[i].Cells[10].Text.ToString());

                            PileInfo pi = db.PileInfo.SingleOrDefault(u => u.PileCode == this.gv.Rows[i].Cells[15].Text.ToString());
                            sid.PileID = pi.PileID;

                            sid.financeCode = this.gv.Rows[i].Cells[16].Text.ToString();
                            sid.StorageTime = Convert.ToDateTime(this.gv.Rows[i].Cells[17].Text.ToString());

                            //这里不唯一要出问题。

                            sid.SupplierID = Convert.ToInt32(this.gv.Rows[i].Cells[25].Text.ToString());

                            var temp = from a in db.CommitInAudited
                                       where a.CommitInID == Convert.ToInt32(Request.QueryString["StorageInID"])
                                       select new { a.MaterialsManager, a.WarehouseWorker, a.MaterialAccounting };
                            var list = temp.ToList();
                            sid.MaterialsManager   = list[i].MaterialsManager;
                            sid.WarehouseWorker    = list[i].WarehouseWorker;
                            sid.MaterialAccounting = list[i].MaterialAccounting;
                            sid.AuditStatus        = this.gv.Rows[i].Cells[22].Text.ToString();
                            sid.AuditTime          = Convert.ToDateTime(this.gv.Rows[i].Cells[23].Text.ToString());
                            sid.DirectorStatus     = "已审批";
                            var SevTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                            sid.DirectorTime = SevTime.First();
                            sid.Remark       = this.gv.Rows[i].Cells[24].Text.ToString();
                            //sid.BatchIndex = this.gv.Rows[i].Cells[20].Text.ToString();
                            sid.Director = reEmpId(SPContext.Current.Web.CurrentUser.LoginName.ToString());
                            db.CommitInDirector.InsertOnSubmit(sid);

                            //写入库存表
                            TableOfStocks tos = new TableOfStocks();
                            tos.StorageInID        = Convert.ToInt32(Request.QueryString["StorageInID"]);
                            tos.StorageInType      = "委外入库";
                            tos.MaterialID         = mi.MaterialID;
                            tos.SpecificationModel = this.gv.Rows[i].Cells[3].Text.ToString();

                            tos.QuantityGentaojian = Convert.ToDecimal(this.gv.Rows[i].Cells[4].Text.ToString());
                            tos.QuantityMetre      = Convert.ToDecimal(this.gv.Rows[i].Cells[5].Text.ToString());
                            tos.QuantityTon        = Convert.ToDecimal(this.gv.Rows[i].Cells[6].Text.ToString());
                            tos.Quantity           = Convert.ToDecimal(this.gv.Rows[i].Cells[7].Text.ToString());
                            tos.CurUnit            = this.gv.Rows[i].Cells[8].Text.ToString();

                            tos.UnitPrice        = sid.UnitPrice;
                            tos.NumberQualified  = 0;
                            tos.PileID           = pi.PileID;
                            tos.financeCode      = sid.financeCode;
                            tos.StorageTime      = sid.StorageTime;
                            tos.SupplierID       = sid.SupplierID;
                            tos.MaterialsManager = list[i].MaterialsManager;
                            tos.WarehouseWorker  = list[i].WarehouseWorker;
                            sid.Remark           = sid.Remark;
                            db.TableOfStocks.InsertOnSubmit(tos);


                            db.SubmitChanges();
                        }

                        //修改完成状态
                        if (!string.IsNullOrEmpty(Request.QueryString["TaskStorageID"]))
                        {
                            TaskStorageIn ts = db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID == Convert.ToInt32(Request.QueryString["TaskStorageID"]));
                            if (ts != null)
                            {
                                ts.TaskState    = "已完成";
                                ts.InspectState = "已审核";



                                ////修改代理任务完成状态

                                //ProxyDirector pd = db.ProxyDirector.SingleOrDefault(u => u.TaskID == Convert.ToInt32(Request.QueryString["TaskStorageID"]) && u.TaskProxy.TaskProxyType.TaskProxyTypeName == "正常入库");
                                //if (pd != null)
                                //{
                                //    TaskProxy tp = db.TaskProxy.SingleOrDefault(u => u.TaskProxyType.TaskProxyTypeName == "正常入库" && u.ProxyPrincipal == pd.TaskProxy.ProxyPrincipal && u.TaskDispose == "未完成");
                                //    tp.TaskDispose = "完成";
                                //}
                            }
                            db.SubmitChanges();
                        }
                    }

                    Response.Redirect("DirectorPass.aspx?StorageInID=" + Request.QueryString["StorageInID"] + "&&TaskStorageID=" + Request.QueryString["TaskStorageID"] + "");
                }
                else
                {
                    using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                    {
                        //任务信息
                        TaskStorageIn tsi = db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID == Convert.ToInt32(Request.QueryString["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   = Convert.ToInt32(Request.QueryString["StorageInID"]);
                        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));
            }
        }
        void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    //decimal count = 0;
                    decimal countcell = 0;
                    for (int a = 0; a < this.gv.Rows.Count; a++)
                    {
                        //switch (this.gv.Rows[a].Cells[6].Text.Trim())
                        //{
                        //    case "根/台/套/件":
                        //        count += Convert.ToDecimal(this.gv.Rows[a].Cells[2].Text.Trim());

                        //        break;
                        //    case "米":
                        //        count += Convert.ToDecimal(this.gv.Rows[a].Cells[3].Text.Trim());

                        //        break;
                        //    case "吨":
                        //        count += Convert.ToDecimal(this.gv.Rows[a].Cells[4].Text.Trim());
                        //        break;
                        //}
                        countcell += Convert.ToDecimal((this.gv.Rows[a].Cells[5].Controls[0] as TextBox).Text.Trim());
                    }
                    if (countcell > _quantity)
                    {
                        lblout.Visible = true;
                        lblout.Text    = "默认填写物资数量为:" + countcell + ",已超出待转线上数值,请修改!";
                        return;
                    }


                    #region modify by adonis 2011-2-15
                    //写入线上库存

                    StockOnline so = new StockOnline();
                    so.OrderNum = MaterialOnLine.TempDataEdit.OrderNum;



                    so.OnlineCode     = MaterialOnLine.TempDataEdit.OnlineCode;
                    so.OnlineDate     = MaterialOnLine.TempDataEdit.OnlineDate;
                    so.CertificateNum = MaterialOnLine.TempDataEdit.CertificateNum;
                    so.OnlineUnit     = MaterialOnLine.TempDataEdit.OnlineUnit;
                    so.CurQuantity    = MaterialOnLine.TempDataEdit.CurQuantity;
                    so.OnlineTotal    = MaterialOnLine.TempDataEdit.OnlineTotal;


                    so.StorageInID       = MaterialOnLine.TempDataEdit.StorageInID;
                    so.StorageInType     = MaterialOnLine.TempDataEdit.StorageInType;
                    so.ReceivingTypeName = MaterialOnLine.TempDataEdit.ReceivingTypeName;
                    so.StorageInCode     = MaterialOnLine.TempDataEdit.StorageInCode;
                    so.BillCode          = MaterialOnLine.TempDataEdit.BillCode;
                    so.MaterialID        = MaterialOnLine.TempDataEdit.MaterialID;
                    so.MaterialCode      = "N/A";

                    so.QuantityGentaojian = MaterialOnLine.TempDataEdit.OnlineTotal;
                    so.QuantityMetre      = MaterialOnLine.TempDataEdit.OnlineTotal;
                    so.QuantityTon        = MaterialOnLine.TempDataEdit.OnlineTotal;

                    so.OfflineGentaojian -= MaterialOnLine.TempDataEdit.QuantityGentaojian;
                    so.OfflineMetre      -= MaterialOnLine.TempDataEdit.QuantityMetre;
                    so.OfflineTon        -= MaterialOnLine.TempDataEdit.QuantityTon;


                    so.CurUnit          = MaterialOnLine.TempDataEdit.CurUnit;
                    so.UnitPrice        = MaterialOnLine.TempDataEdit.UnitPrice;
                    so.Amount           = MaterialOnLine.TempDataEdit.Amount;
                    so.ExpectedProject  = MaterialOnLine.TempDataEdit.ExpectedProject;
                    so.Remark           = MaterialOnLine.TempDataEdit.Remark;
                    so.BatchIndex       = MaterialOnLine.TempDataEdit.BatchIndex;
                    so.ManufacturerID   = MaterialOnLine.TempDataEdit.ManufacturerID;
                    so.SupplierID       = MaterialOnLine.TempDataEdit.SupplierID;
                    so.StorageID        = MaterialOnLine.TempDataEdit.StorageID;
                    so.PileID           = MaterialOnLine.TempDataEdit.PileID;
                    so.MaterialsManager = MaterialOnLine.TempDataEdit.MaterialsManager;
                    so.AssetsManager    = MaterialOnLine.TempDataEdit.AssetsManager;
                    so.StorageTime      = MaterialOnLine.TempDataEdit.StorageTime;

                    so.OnlineUnitPrice = MaterialOnLine.TempDataEdit.OnlineUnitPrice;
                    so.Creator         = MaterialOnLine.TempDataEdit.Creator;

                    var SaveTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                    so.CreateTime = SaveTime.First();
                    db.StockOnline.InsertOnSubmit(so);


                    //修改库存表线上状态
                    TableOfStocks to = db.TableOfStocks.SingleOrDefault(u => u.StocksID == MaterialOnLine.TempDataEdit.iSocksID);

                    //转线上后,库存剩余数量
                    switch (so.OnlineUnit)
                    {
                    case "根/台/套/件":
                        to.QuantityGentaojian -= so.CurQuantity;
                        break;

                    case "米":
                        to.QuantityMetre -= so.CurQuantity;
                        break;

                    case "吨":
                        to.QuantityTon -= so.CurQuantity;
                        break;
                    }
                    //so.QuantityGentaojian = to.
                    //修改库存表对应单位数量
                    to.QuantityGentaojian -= so.QuantityGentaojian;
                    to.QuantityMetre      -= so.QuantityMetre;
                    to.QuantityTon        -= so.QuantityTon;



                    #endregion



                    for (int i = 0; i < this.gv.Rows.Count; i++)
                    {
                        FlowDetailsOffline fdo = new FlowDetailsOffline();
                        fdo.TableOfStocksID   = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 1].Text.Trim());
                        fdo.StorageType       = this.gv.Rows[i].Cells[7].Text.Trim();
                        fdo.StorageOutCode    = this.gv.Rows[i].Cells[0].Text.Trim();
                        fdo.StorageOutProject = Convert.ToInt32(this.gv.Rows[i].Cells[this.gv.Columns.Count - 2].Text.Trim());
                        //fdo.CurUnit = this.gv.Rows[i].Cells[6].Text.Trim();

                        TextBox tboxCurQuantity = (TextBox)this.gv.Rows[i].Cells[5].Controls[0];
                        fdo.CurQuantity = Convert.ToDecimal(tboxCurQuantity.Text.Trim());

                        TextBox Curunit = (TextBox)this.gv.Rows[i].Cells[6].Controls[0];
                        fdo.CurUnit = Curunit.Text.Trim();

                        fdo.RealGentaojian = Convert.ToDecimal(this.gv.Rows[i].Cells[2].Text.Trim());
                        fdo.RealMetre      = Convert.ToDecimal(this.gv.Rows[i].Cells[3].Text.Trim());
                        fdo.RealTon        = Convert.ToDecimal(this.gv.Rows[i].Cells[4].Text.Trim());
                        fdo.Creator        = db.EmpInfo.SingleOrDefault(u => u.Account == SPContext.Current.Web.CurrentUser.LoginName).EmpID;
                        var SevTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { });
                        fdo.CreateTime = SevTime.First();
                        db.FlowDetailsOffline.InsertOnSubmit(fdo);
                        db.SubmitChanges();
                    }
                    //解开静态类锁
                    MaterialOnLine.TempDataEdit.locked = false;
                }
                Response.Redirect("MaterialOnLineManage.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));
            }
            //写入物资追踪表
        }
Example #6
0
        void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //将确认结果保存到数据库
                using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    int empid = db.EmpInfo.SingleOrDefault(u => u.Account == SPContext.Current.Web.CurrentUser.LoginName).EmpID;
                    foreach (GridViewRow gvr in spgvMaterial.Rows)
                    {
                        if (bWriteOff)
                        {
                            switch (gvr.Cells[16].Text)
                            {
                            case "线上":
                                StockOnline sol = StorageToOnLine(gvr);
                                sol.CreateTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                                sol.Creator    = empid;
                                db.StockOnline.InsertOnSubmit(sol);
                                break;

                            case "线下":
                                TableOfStocks tos = StorageToOffLine(gvr);
                                tos.CreateTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                                tos.Creator    = empid;
                                db.TableOfStocks.InsertOnSubmit(tos);
                                break;

                            case "回收合格":
                                QualifiedStocks qfs = StorageToQualified(gvr);
                                qfs.CreateTime = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                                qfs.Creator    = empid;
                                db.QualifiedStocks.InsertOnSubmit(qfs);
                                break;
                            }
                        }
                        else
                        {
                            QualifiedStocks qs = new QualifiedStocks();
                            qs.Gentaojian        = Convert.ToDecimal(gvr.Cells[4].Text);
                            qs.Metre             = Convert.ToDecimal(gvr.Cells[5].Text);
                            qs.Ton               = Convert.ToDecimal(gvr.Cells[6].Text);
                            qs.UnitPrice         = Convert.ToDecimal(gvr.Cells[7].Text);
                            qs.CurUnit           = gvr.Cells[8].Text;
                            qs.Amount            = qs.UnitPrice * Convert.ToDecimal(gvr.Cells[GetPricingIndex(qs.CurUnit)].Text);
                            qs.StorageTime       = Convert.ToDateTime(gvr.Cells[9].Text);
                            qs.RetrieveTime      = Convert.ToDateTime(gvr.Cells[10].Text);
                            qs.Remark            = (gvr.Cells[11].Controls[0] as TextBox).Text.Trim();
                            qs.StorageID         = Convert.ToInt32(gvr.Cells[13].Text);
                            qs.PileID            = Convert.ToInt32(gvr.Cells[14].Text);
                            qs.ManufactureID     = Convert.ToInt32(gvr.Cells[15].Text);
                            qs.MaterialID        = Convert.ToInt32(gvr.Cells[16].Text);
                            qs.RetrieveProjectID = projectid;
                            qs.CreateTime        = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                            qs.Creator           = db.EmpInfo.SingleOrDefault(u => u.Account == SPContext.Current.Web.CurrentUser.LoginName).EmpID;
                            db.QualifiedStocks.InsertOnSubmit(qs);
                        }
                    }

                    //结束当前任务
                    db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID.Equals(_taskid)).TaskState = "已完成";

                    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));
            }
        }
Example #7
0
        void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //将审核结果保存到数据库
                using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
                {
                    _taskid = Convert.ToInt32(Request.QueryString["StockTransferTaskID"]);
                    StockTransferTask st1 = db.StockTransferTask.SingleOrDefault(a => a.StockTransferTaskID == _taskid);
                    //页面已处理完毕就直接跳转到发送任务界面
                    if (((Panel)GetControltByMaster("PanelDone")).Visible == true)
                    {
                        Response.Redirect("StockTransferCreateTask.aspx?StockTransferID=" + st1.StockTransferID + "&&TaskType=生产组长审核信息&&BackUrl=" + HttpContext.Current.Request.Url.PathAndQuery);
                    }



                    if (this.chbAgree.Checked)
                    {
                        //通過
                        //验证是否都有内容
                        _taskid = Convert.ToInt32(Request.QueryString["StockTransferTaskID"]);
                        StockTransferTask st = db.StockTransferTask.SingleOrDefault(a => a.StockTransferTaskID == _taskid);
                        st.AcceptTime   = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                        st.AuditOpinion = this.txtOpinion.Text.Trim();
                        st.AuditStatus  = "审核通过";
                        st.TaskState    = "已完成";
                        //db.SubmitChanges();
                        var all = from a in db.StockTransferDetail
                                  where a.StockTransferID == st.StockTransferID
                                  select a;
                        bool done = true;
                        foreach (var single in all)
                        {
                            switch (single.StocksStatus)
                            {
                            case "线上":
                                #region 改线上
                                var     ul = db.StockOnline.SingleOrDefault(a => a.StockOnlineID == single.StocksID);
                                decimal gen, meter, ton;
                                gen   = decimal.Parse((ul.QuantityGentaojian - single.QuantityGentaojian).ToString());
                                meter = decimal.Parse((ul.QuantityMetre - single.QuantityMetre).ToString());
                                ton   = decimal.Parse((ul.QuantityTon - single.QuantityTon).ToString());
                                if (gen < 0 || meter < 0 || ton < 0)
                                {
                                    done = false;
                                }
                                //创建新纪录//修改原纪录
                                StockOnline so = new StockOnline();

                                so.Amount        = ul.Amount;
                                so.AssetsManager = ul.AssetsManager;
                                so.BatchIndex    = ul.BatchIndex;
                                so.BillCode      = ul.BillCode;

                                so.CurUnit           = ul.CurUnit;
                                so.ExpectedProject   = ul.ExpectedProject;
                                so.ManufacturerID    = ul.ManufacturerID;
                                so.MaterialCode      = ul.MaterialCode;
                                so.MaterialID        = ul.MaterialID;
                                so.MaterialsManager  = ul.MaterialsManager;
                                so.OfflineGentaojian = ul.OfflineGentaojian;
                                so.OfflineMetre      = ul.OfflineMetre;
                                so.OfflineTon        = ul.OfflineTon;
                                so.ReceivingTypeName = ul.ReceivingTypeName;
                                so.Remark            = ul.Remark;
                                so.StorageInCode     = ul.StorageInCode;
                                so.StorageInID       = ul.StorageInID;
                                so.StorageInType     = ul.StorageInType;
                                so.StorageTime       = ul.StorageTime;
                                so.SupplierID        = ul.SupplierID;
                                so.UnitPrice         = ul.UnitPrice;
                                so.CertificateNum    = ul.CertificateNum;
                                so.CreateTime        = DateTime.Now;
                                so.Creator           = ul.Creator;
                                switch (ul.OnlineUnit)
                                {
                                case "根/台/套/件":
                                    so.CurQuantity = single.QuantityGentaojian;

                                    ul.CurQuantity = gen;
                                    // so.OnlineTotal = gen * ul.OnlineUnitPrice;
                                    break;

                                case "米":
                                    so.CurQuantity = single.QuantityMetre;

                                    ul.CurQuantity = meter;
                                    break;

                                case "吨":
                                    so.CurQuantity = single.QuantityTon;

                                    ul.CurQuantity = ton;
                                    break;
                                }
                                so.OnlineCode         = ul.OnlineCode;
                                so.OnlineDate         = ul.OnlineDate;
                                so.OnlineTotal        = so.CurQuantity * ul.OnlineUnitPrice;
                                ul.OnlineTotal        = ul.CurQuantity * ul.OnlineUnitPrice;
                                so.OnlineUnit         = ul.OnlineUnit;
                                so.OnlineUnitPrice    = ul.OnlineUnitPrice;
                                so.OrderNum           = ul.OrderNum;
                                so.QuantityGentaojian = single.QuantityGentaojian;
                                ul.QuantityGentaojian = gen;
                                so.QuantityMetre      = single.QuantityMetre;
                                ul.QuantityMetre      = meter;
                                so.QuantityTon        = single.QuantityTon;
                                ul.QuantityTon        = ton;

                                //  so.TableOfStocksID = ul.TableOfStocksID;
                                so.PileID = single.TargetPile;
                                db.StockOnline.InsertOnSubmit(so);

                                #endregion
                                break;

                            case "线下":
                                #region 改线下
                                var un = db.TableOfStocks.SingleOrDefault(a => a.StocksID == single.StocksID);
                                gen   = decimal.Parse((un.QuantityGentaojian - single.QuantityGentaojian).ToString());
                                meter = decimal.Parse((un.QuantityMetre - single.QuantityMetre).ToString());
                                ton   = decimal.Parse((un.QuantityTon - single.QuantityTon).ToString());
                                if (gen < 0 || meter < 0 || ton < 0)
                                {
                                    done = false;
                                }
                                //创建新纪录//修改原纪录
                                TableOfStocks tos = new TableOfStocks();
                                tos.AssetsManager      = un.AssetsManager;
                                tos.BatchIndex         = un.BatchIndex;
                                tos.BillCode           = un.BillCode;
                                tos.CreateTime         = DateTime.Now;
                                tos.Creator            = un.Creator;
                                tos.CurUnit            = un.CurUnit;
                                tos.ExpectedProject    = un.ExpectedProject;
                                tos.ManufacturerID     = un.ManufacturerID;
                                tos.MaterialCode       = un.MaterialCode;
                                tos.MaterialID         = un.MaterialID;
                                tos.MaterialsManager   = un.MaterialsManager;
                                tos.PileID             = single.TargetPile;
                                tos.QuantityGentaojian = single.QuantityGentaojian;
                                un.QuantityGentaojian  = gen;
                                tos.QuantityMetre      = single.QuantityMetre;
                                un.QuantityMetre       = meter;
                                tos.QuantityTon        = single.QuantityTon;
                                un.QuantityTon         = ton;
                                tos.ReceivingTypeName  = un.ReceivingTypeName;
                                tos.Remark             = un.Remark;
                                tos.StorageID          = single.PileInfo.StorageInfo.StorageID;
                                tos.StorageInCode      = un.StorageInCode;
                                tos.StorageInID        = un.StorageInID;
                                tos.StorageInType      = un.StorageInType;
                                tos.StorageTime        = un.StorageTime;
                                tos.SupplierID         = un.SupplierID;
                                tos.UnitPrice          = un.UnitPrice;
                                switch (tos.CurUnit)
                                {
                                case "根/台/套/件":
                                    tos.Amount = decimal.Parse(tos.QuantityGentaojian.ToString()) * tos.UnitPrice;
                                    un.Amount  = gen * un.UnitPrice;
                                    // so.OnlineTotal = gen * ul.OnlineUnitPrice;
                                    break;

                                case "米":
                                    tos.Amount = decimal.Parse(tos.QuantityMetre.ToString()) * tos.UnitPrice;
                                    un.Amount  = meter * un.UnitPrice;
                                    break;

                                case "吨":
                                    tos.Amount = decimal.Parse(tos.QuantityTon.ToString()) * tos.UnitPrice;
                                    un.Amount  = ton * un.UnitPrice;
                                    break;
                                }
                                db.TableOfStocks.InsertOnSubmit(tos);
                                #endregion
                                break;

                            case "回收合格":
                                #region  回收
                                var ur = db.QualifiedStocks.SingleOrDefault(a => a.StocksID == single.StocksID);
                                gen   = decimal.Parse((ur.Gentaojian - single.QuantityGentaojian).ToString());
                                meter = decimal.Parse((ur.Metre - single.QuantityMetre).ToString());
                                ton   = decimal.Parse((ur.Ton - single.QuantityTon).ToString());
                                if (gen < 0 || meter < 0 || ton < 0)
                                {
                                    done = false;
                                }
                                //创建新纪录//修改原纪录
                                QualifiedStocks qs = new QualifiedStocks();
                                qs.CurUnit           = ur.CurUnit;
                                qs.ManufactureID     = ur.ManufactureID;
                                qs.MaterialID        = ur.MaterialID;
                                qs.PileID            = single.TargetPile;
                                qs.Remark            = ur.Remark;
                                qs.RetrieveProjectID = ur.RetrieveProjectID;
                                qs.RetrieveTime      = ur.RetrieveTime;
                                qs.StorageID         = single.PileInfo.StorageInfo.StorageID;
                                qs.StorageTime       = ur.StorageTime;
                                qs.UnitPrice         = ur.UnitPrice;
                                qs.Gentaojian        = decimal.Parse(single.QuantityGentaojian.ToString());
                                ur.Gentaojian        = gen;
                                qs.Metre             = decimal.Parse(single.QuantityMetre.ToString());
                                ur.Metre             = meter;
                                qs.Ton = decimal.Parse(single.QuantityTon.ToString());
                                ur.Ton = ton;
                                switch (qs.CurUnit)
                                {
                                case "根/台/套/件":
                                    qs.Amount = decimal.Parse(qs.Gentaojian.ToString()) * qs.UnitPrice;
                                    ur.Amount = gen * ur.UnitPrice;
                                    // so.OnlineTotal = gen * ul.OnlineUnitPrice;
                                    break;

                                case "米":
                                    qs.Amount = decimal.Parse(qs.Metre.ToString()) * qs.UnitPrice;
                                    ur.Amount = meter * ur.UnitPrice;
                                    break;

                                case "吨":
                                    qs.Amount = decimal.Parse(qs.Ton.ToString()) * qs.UnitPrice;
                                    ur.Amount = ton * ur.UnitPrice;
                                    break;
                                }
                                db.QualifiedStocks.InsertOnSubmit(qs);
                                #endregion
                                break;
                            }
                            if (!done)
                            {
                                break;
                            }
                        }
                        if (done)
                        {
                            db.SubmitChanges();
                        }
                        else
                        {
                            ClientScript.RegisterClientScriptBlock(typeof(string), "提示", string.Format("<script>alert('{0}')</script>", "移动数目超过库存数,请检查数据!"));
                        }
                        //Response.Redirect("StockTransferCreateTask.aspx?StockTransferID=" + st.StockTransferID + "&&TaskType=生产组长审核信息&&BackUrl=" + HttpContext.Current.Request.Url.PathAndQuery);
                    }
                    else
                    {
                        //未通過
                        //通過
                        //验证是否都有内容
                        _taskid = Convert.ToInt32(Request.QueryString["StockTransferTaskID"]);
                        StockTransferTask st = db.StockTransferTask.SingleOrDefault(a => a.StockTransferTaskID == _taskid);
                        st.AcceptTime   = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                        st.AuditOpinion = this.txtOpinion.Text.Trim();
                        st.AuditStatus  = "审核未通过";
                        st.TaskState    = "已完成";
                        //写入新的内容

                        StockTransferTask stt = new StockTransferTask();
                        stt.Remark          = this.txtOpinion.Text.Trim();
                        stt.StockTransferID = st.StockTransferID;
                        stt.TaskCreaterID   = st.TaskTargetID;
                        stt.TaskInType      = "移库任务";
                        stt.TaskState       = "未完成";
                        stt.TaskTargetID    = st.TaskCreaterID;
                        stt.TaskTitle       = st.TaskTitle + "[审核未通过]";
                        stt.TaskType        = "发起人修改";
                        stt.CreateTime      = db.ExecuteQuery <DateTime>("select  getdate()", new object[] { }).First();
                        db.StockTransferTask.InsertOnSubmit(stt);
                        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));
            }
        }