示例#1
0
        /// <summary>
        /// 添加质检
        /// </summary>
        /// <param name="model">质检申请单</param>
        /// <param name="detailList">明细信息</param>
        /// <param name="htExtAttr">扩展属性</param>
        /// <returns></returns>
        public static bool AddReport(StorageQualityCheckReportModel model, List<StorageQualityCheckReportDetailModel> detail, Hashtable htExtAttr)
        {

            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            try
            {

                bool result = false;
                LogInfoModel logModel = InitLogInfo(model.ReportNo);
                logModel.Element = ConstUtil.LOG_PROCESS_INSERT;
                result = CheckReportDBHelper.AddReport(model, detail, htExtAttr);
                if (!result)
                {
                    logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                }
                else
                {
                    logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                    model.ID = IDIdentityUtil.GetIDIdentity("officedba.QualityCheckReport");
                }
                LogDBHelper.InsertLog(logModel);
                return result;
            }
            catch (Exception ex)
            {
                WriteSystemLog(userInfo, ex);
                return false;
            }
        }
    protected void btnImport_Click(object sender, ImageClickEventArgs e)
    {
        string companyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
        StorageQualityCheckReportModel model = new StorageQualityCheckReportModel();
        model.CompanyCD = companyCD;
        model.Title = this.txtSubject.Text.Trim();
        model.ReportNo = this.txtReportNo.Text.Trim();
        model.FromType = sltFromType.Value.Trim();
        model.FromReportNo = this.tbReportNo.Value;
        model.CheckType = sltCheckType.Value.Trim();
        model.CheckMode = sltCheckMode.Value.Trim();
        model.Checker = int.Parse(hiddenChecker.Value);
        model.ApplyDeptID = int.Parse(hiddenCheckDept.Value);
        string FlowStatus = ddlFlowStatus.Value;
        string theBeginTime = BeginTime.Value;
        string theEndTime = EndTime.Value;
        model.BillStatus = this.sltBillStatus.Value;
        int TotalCount = 0;

        model.Attachment = " ID Desc";
        if (this.hiddenOrder.Value != "0")
        {
            string[] myOrder = this.hiddenOrder.Value.Split('_');
            if (myOrder[1] == "a")
            {
                model.Attachment = myOrder[0] + " asc ";
            }
            else
            {
                model.Attachment = myOrder[0] + " desc ";
            }
        }
        model.Creator = -100;
        model.Confirmor = -100;

        string EFIndex = GetBillExAttrControl1.GetExtIndexValue;
        string EFDesc = GetBillExAttrControl1.GetExtTxtValue;

        DataTable dt = CheckReportBus.SearchReport(model, theBeginTime, theEndTime, FlowStatus, EFIndex, EFDesc, ref TotalCount);

        //导出标题
        string headerTitle = "单据编号|单据主题|源单类型|往来单位|往来单位类别|质检类别|检验方式|报检人员|报检部门|报检日期|单据状态|审批状态";
        string[] header = headerTitle.Split('|');

        //导出标题所对应的列字段名称
        string columnFiled = "ReportNo|Title|FromTypeName|OtherCorpName|BigTypeName|CheckTypeName|CheckModeName|EmployeeName|DeptName|CheckDate|BillStatus|FlowStatus";
        string[] field = columnFiled.Split('|');

        XBase.Common.OutputToExecl.ExportToTable(this.Page, dt, header, field, "质检报告单列表");
    }
        /// <summary>
        /// 获取质检报告明细信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static DataTable GetReportDetailInfo(StorageQualityCheckReportModel model)
        {

            #region 查询语句
            //查询SQL拼写
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("select * from (");
            sql.AppendLine("SELECT     c.ID as DetailID,c.CheckStandard, e.EmployeeName, d.DeptName, c.SortNo, c.CheckItem, isnull(c.CheckValue,'') as CheckValue, c.CheckNum, c.PassNum, c.NotPassNum,");
            sql.AppendLine("                      isnull(c.StandardValue,'') as StandardValue, c.NormUpLimit, c.LowerLimit, isnull(c.CheckResult,'') as CheckResult, c.isPass, c.Checker, c.CheckDeptID, c.Remark, c.ModifiedDate, c.ModifiedUserID  ");
            sql.AppendLine("FROM                  officedba.CheckReportDetail AS c LEFT  JOIN                                                                                                      ");
            sql.AppendLine("                      officedba.EmployeeInfo AS e ON c.Checker = e.ID left JOIN                                                                                   ");
            sql.AppendLine("                      officedba.DeptInfo AS d ON c.CheckDeptID = d.ID                                                                                              ");
            sql.AppendLine(" where c.ReportNo=(select top 1 ReportNo from officedba.QualityCheckReport where CompanyCD=@CompanyCD and ID=@ID) and c.CompanyCD=@CompanyCD");
            sql.AppendLine(") as info ");
            //sql += " where CompanyCD=@CompanyCD";

            #endregion

            //定义查询的命令
            SqlCommand comm = new SqlCommand();
            //添加公司代码参数
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", model.ID.ToString()));


            //指定命令的SQL文
            comm.CommandText = sql.ToString();
            //执行查询
            return SqlHelper.ExecuteSearch(comm);
        }
        /// <summary>
        /// 更新汇报单
        /// </summary>
        /// <param name="model">汇报单</param>
        /// <param name="detailList">明细</param>
        /// <param name="SortID"></param>
        /// <param name="htExtAttr">扩展属性</param>
        /// <returns></returns>
        public static bool UpdateReport(StorageQualityCheckReportModel model, List<StorageQualityCheckReportDetailModel> detailList, string[] SortID, Hashtable htExtAttr)
        {
            string loginUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID;//[待修改]
            ArrayList sqllist = new ArrayList();
            //string loginUserID = "admin123";
            if (string.IsNullOrEmpty(model.ReportNo))
            {
                return false;
            }
            #region  基本信息
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" UPDATE [officedba].[QualityCheckReport]  ");
            sql.AppendLine("    SET [CompanyCD] = @CompanyCD                  ");
            sql.AppendLine("       ,[ReportNo] =@ReportNo                     ");
            sql.AppendLine("       ,[Title] = @Title                          ");
            sql.AppendLine("       ,[FromType] = @FromType                    ");
            sql.AppendLine("       ,[ReportID] = @ReportID                    ");
            sql.AppendLine("       ,[FromLineNo] = @FromLineNo                ");
            sql.AppendLine("       ,[CheckType] = @CheckType                  ");
            sql.AppendLine("       ,[CheckMode] = @CheckMode                  ");
            sql.AppendLine("       ,[ProductID] = @ProductID                  ");
            sql.AppendLine("       ,[ApplyUserID] =@ApplyUserID               ");
            sql.AppendLine("       ,[ApplyDeptID] =@ApplyDeptID               ");
            sql.AppendLine("       ,[Checker] =@Checker                       ");
            sql.AppendLine("       ,[CheckDeptId] = @CheckDeptId              ");
            sql.AppendLine("       ,[CheckDate] =@CheckDate                   ");

            sql.AppendLine("       ,[CheckContent] = @CheckContent            ");

            sql.AppendLine("       ,[CheckNum] =@CheckNum                     ");
            if (model.SampleNum != -99999)
            {
                sql.AppendLine("       ,[SampleNum] =@SampleNum                   ");
            }
            sql.AppendLine("       ,[PassNum] =@PassNum                       ");
            sql.AppendLine("       ,[PassPercent] =@PassPercent               ");
            sql.AppendLine("       ,[NoPass] =@NoPass                         ");
            sql.AppendLine("       ,[isPass] =@isPass                         ");
            sql.AppendLine("       ,[isRecheck] =@isRecheck                   ");
            sql.AppendLine("       ,FromDetailID=@FromDetailID");

            sql.AppendLine(" ,DeptID=@DeptID");


            sql.AppendLine(" ,Principal=@Principal");

            sql.AppendLine("       ,[BillStatus] = @BillStatus                ");
            sql.AppendLine("       ,[ModifiedDate] =@ModifiedDate             ");
            sql.AppendLine("       ,[ModifiedUserID] = @ModifiedUserID        ");

            sql.AppendLine("       ,[OtherCorpName] =@OtherCorpName           ");

            sql.AppendLine("       ,[CorpBigType] = @CorpBigType              ");
            sql.AppendLine("       ,[FromReportNo] =@FromReportNo             ");
            sql.AppendLine("       ,[OtherCorpID] =@OtherCorpID               ");

            sql.AppendLine("       ,[Remark] = @Remark                        ");



            sql.AppendLine("       ,[Attachment] =@Attachment                 ");


            sql.AppendLine("       ,[CheckStandard] =@CheckStandard           ");

            sql.AppendLine("       ,[CheckResult] = @CheckResult              ");


            sql.AppendLine(" where ID=@ID and CompanyCD=@CompanyCD ");

            SqlCommand comm = new SqlCommand();

            comm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameter("@ReportNo", model.ReportNo));
            comm.Parameters.Add(SqlHelper.GetParameter("@Title", model.Title));
            comm.Parameters.Add(SqlHelper.GetParameter("@FromType", model.FromType));
            comm.Parameters.Add(SqlHelper.GetParameter("@ReportID", model.ReportID));
            comm.Parameters.Add(SqlHelper.GetParameter("@FromLineNo", model.FromLineNo));
            comm.Parameters.Add(SqlHelper.GetParameter("@CheckType", model.CheckType));
            comm.Parameters.Add(SqlHelper.GetParameter("@CheckMode", model.CheckMode));
            comm.Parameters.Add(SqlHelper.GetParameter("@ProductID", model.ProductID));
            comm.Parameters.Add(SqlHelper.GetParameter("@ApplyUserID", model.ApplyUserID));
            comm.Parameters.Add(SqlHelper.GetParameter("@ApplyDeptID", model.ApplyDeptID));
            comm.Parameters.Add(SqlHelper.GetParameter("@Checker", model.Checker));
            comm.Parameters.Add(SqlHelper.GetParameter("@CheckDeptId", model.CheckDeptId));
            comm.Parameters.Add(SqlHelper.GetParameter("@CheckDate", model.CheckDate));

            comm.Parameters.Add(SqlHelper.GetParameter("@CheckContent", model.CheckContent));

            comm.Parameters.Add(SqlHelper.GetParameter("@CheckNum", model.CheckNum));
            if (model.SampleNum != -99999)
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@SampleNum", model.SampleNum));//
            }
            //comm.Parameters.Add(SqlHelper.GetParameter("@SampleBadNum", model.SampleBadNum));
            //comm.Parameters.Add(SqlHelper.GetParameter("@SamplePassNum", model.SamplePassNum));
            comm.Parameters.Add(SqlHelper.GetParameter("@PassNum", model.PassNum));
            comm.Parameters.Add(SqlHelper.GetParameter("@PassPercent", model.PassPercent));
            comm.Parameters.Add(SqlHelper.GetParameter("@FromDetailID", model.FromDetailID));
            comm.Parameters.Add(SqlHelper.GetParameter("@NoPass", model.NoPass));
            comm.Parameters.Add(SqlHelper.GetParameter("@isPass", model.isPass));
            comm.Parameters.Add(SqlHelper.GetParameter("@isRecheck", model.isRecheck));
            comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
            comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
            //comm.Parameters.Add(SqlHelper.GetParameter("@OtherCorpNo", model.OtherCorpNo));

            comm.Parameters.Add(SqlHelper.GetParameter("@OtherCorpName", model.OtherCorpName));

            comm.Parameters.Add(SqlHelper.GetParameter("@CorpBigType", model.CorpBigType));
            comm.Parameters.Add(SqlHelper.GetParameter("@FromReportNo", model.FromReportNo));
            //  comm.Parameters.Add(SqlHelper.GetParameter("@ReportName", model.ReportName));
            comm.Parameters.Add(SqlHelper.GetParameter("@OtherCorpID", model.OtherCorpID));
            comm.Parameters.Add(SqlHelper.GetParameter("@ID", model.ID));

            comm.Parameters.Add(SqlHelper.GetParameter("@DeptID", model.Dept));


            comm.Parameters.Add(SqlHelper.GetParameter("@Principal", model.Principal));

            if (model.BillStatus == "2")
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@BillStatus", "3"));
            }
            else
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@BillStatus", model.BillStatus));
            }

            comm.Parameters.Add(SqlHelper.GetParameter("@Remark", model.Remark));



            comm.Parameters.Add(SqlHelper.GetParameter("@Attachment", model.Attachment));


            comm.Parameters.Add(SqlHelper.GetParameter("@CheckStandard", model.CheckStandard));


            comm.Parameters.Add(SqlHelper.GetParameter("@CheckResult", model.CheckResult));

            comm.CommandText = sql.ToString();
            sqllist.Add(comm);

            // 更新扩展属性
            SqlCommand commExtAttr = UpdateExtAttr(model, htExtAttr);
            if (commExtAttr != null)
            {
                sqllist.Add(commExtAttr);
            }
            #endregion

            #region  明细
            if (SortID.Length > 0)
            {
                string delsql = "delete officedba.CheckReportDetail where CompanyCD=@CompanyCD and ReportNo=@ReportNo ";
                SqlCommand delcomm = new SqlCommand();
                delcomm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                delcomm.Parameters.Add(SqlHelper.GetParameter("@ReportNo", model.ReportNo));
                delcomm.CommandText = delsql;
                sqllist.Add(delcomm);
                if (SortID[0] != null && SortID[0] != "")
                {
                    for (int i = 0; i < detailList.Count; i++)
                    {
                        StringBuilder sbsql = new StringBuilder();
                        sbsql.AppendLine("INSERT INTO [officedba].[CheckReportDetail]");
                        sbsql.AppendLine("([ReportNo],[SortNo],[CheckItem]");
                        if (!string.IsNullOrEmpty(detailList[i].CheckValue))
                        {
                            sbsql.AppendLine(",[CheckValue]");
                        }
                        sbsql.AppendLine(",[CheckNum]");
                        if (!string.IsNullOrEmpty(detailList[i].StandardValue))
                        {
                            sbsql.AppendLine(",[StandardValue]");
                        }
                        sbsql.AppendLine(",[isPass],[Checker],[CheckDeptID],[ModifiedDate],[ModifiedUserID]");
                        if (!string.IsNullOrEmpty(detailList[i].NormUpLimit))
                        {
                            sbsql.AppendLine(",[NormUpLimit]");
                        }
                        if (!string.IsNullOrEmpty(detailList[i].LowerLimit))
                        {
                            sbsql.AppendLine(",[LowerLimit]");
                        }
                        if (!string.IsNullOrEmpty(detailList[i].CheckStandard))
                        {
                            sbsql.AppendLine(",[CheckStandard]");
                        }
                        if (!string.IsNullOrEmpty(detailList[i].CheckResult))
                        {
                            sbsql.AppendLine(",[CheckResult]");
                        }
                        if (!string.IsNullOrEmpty(detailList[i].Remark))
                        {
                            sbsql.AppendLine(",[Remark]");
                        }
                        if (detailList[i].PassNum != -1)
                        {
                            sbsql.AppendLine(",[PassNum]");
                        }
                        if (detailList[i].NotPassNum != -1)
                        {
                            sbsql.AppendLine(",[NotPassNum]");
                        }
                        //if (detailList[i].BadNum != -1)
                        //{
                        //    sbsql.AppendLine(",[BadNum]");
                        //}
                        sbsql.AppendLine(" ,[CompanyCD])");
                        sbsql.AppendLine("  values(");
                        sbsql.AppendLine(" @ReportNo,@SortNo,@CheckItem");
                        if (!string.IsNullOrEmpty(detailList[i].CheckValue))
                        {
                            sbsql.AppendLine(",@CheckValue");
                        }
                        sbsql.AppendLine(",@CheckNum");
                        if (!string.IsNullOrEmpty(detailList[i].StandardValue))
                        {
                            sbsql.AppendLine(",@StandardValue");
                        }
                        sbsql.AppendLine(",@isPass,@Checker,@CheckDeptID,@ModifiedDate,@ModifiedUserID");
                        if (!string.IsNullOrEmpty(detailList[i].NormUpLimit))
                        {
                            sbsql.AppendLine(",@NormUpLimit");
                        }
                        if (!string.IsNullOrEmpty(detailList[i].LowerLimit))
                        {
                            sbsql.AppendLine(",@LowerLimit");
                        }
                        if (!string.IsNullOrEmpty(detailList[i].CheckStandard))
                        {
                            sbsql.AppendLine(",@CheckStandard");
                        }
                        if (!string.IsNullOrEmpty(detailList[i].CheckResult))
                        {
                            sbsql.AppendLine(",@CheckResult");
                        }
                        if (!string.IsNullOrEmpty(detailList[i].Remark))
                        {
                            sbsql.AppendLine("       , @Remark");
                        }
                        if (detailList[i].PassNum != -1)
                        {
                            sbsql.AppendLine("               ,@PassNum");
                        }
                        if (detailList[i].NotPassNum != -1)
                        {
                            sbsql.AppendLine("           ,@NotPassNum");
                        }
                        //if (detailList[i].BadNum != -1)
                        //{
                        //    sbsql.AppendLine("                ,@BadNum");
                        //}
                        sbsql.AppendLine("  ,@CompanyCD)");
                        SqlCommand sqlcomm = new SqlCommand();

                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@ReportNo", model.ReportNo));
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@SortNo", detailList[i].SortNo));
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckItem", detailList[i].CheckItem));
                        if (!string.IsNullOrEmpty(detailList[i].CheckStandard))
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckStandard", detailList[i].CheckStandard));
                        }
                        if (!string.IsNullOrEmpty(detailList[i].CheckValue))
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckValue", detailList[i].CheckValue));
                        }
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckNum", detailList[i].CheckNum));
                        if (!string.IsNullOrEmpty(detailList[i].StandardValue))
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@StandardValue", detailList[i].StandardValue));
                        }
                        if (!string.IsNullOrEmpty(detailList[i].NormUpLimit))
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@NormUpLimit", detailList[i].NormUpLimit));
                        }
                        if (!string.IsNullOrEmpty(detailList[i].LowerLimit))
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@LowerLimit", detailList[i].LowerLimit));
                        }
                        if (!string.IsNullOrEmpty(detailList[i].CheckResult))
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckResult", detailList[i].CheckResult));
                        }
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@isPass", detailList[i].isPass));
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@Checker", detailList[i].Checker));
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckDeptID", detailList[i].CheckDeptID));
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
                        if (!string.IsNullOrEmpty(detailList[i].Remark))
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@Remark", detailList[i].Remark));
                        }
                        if (detailList[i].PassNum != -1)
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@PassNum", detailList[i].PassNum));
                        }
                        if (detailList[i].NotPassNum != -1)
                        {
                            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@NotPassNum", detailList[i].NotPassNum));
                        }
                        //if (detailList[i].BadNum != -1)
                        //{
                        //    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@BadNum", detailList[i].BadNum));
                        //}
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                        sqlcomm.CommandText = sbsql.ToString();
                        sqllist.Add(sqlcomm);
                    }
                }
            }
            #endregion
            if (SqlHelper.ExecuteTransWithArrayList(sqllist))
            {
                return true;
            }
            else
            {
                return false;
            }

        }
示例#5
0
 public static string GetCheckSave(StorageQualityCheckReportModel model)
 {
     return CheckReportDBHelper.GetCheckSave(model);
 }
 public static bool UnUpdatePur(StorageQualityCheckReportModel model)
 {
     ArrayList list = new ArrayList();
     StringBuilder sql = new StringBuilder();
     sql.AppendLine("update officedba.PurchaseArriveDetail set CheckedCount=isnull(CheckedCount,0)-@CheckedCount,PassCount=isnull(PassCount,0)-@PassCount,NotPassCount=isnull(NotPassCount,0)-@NotPassCount");
     if (model.FromType == "4")
     {
         sql.AppendLine(" ,ApplyCheckCount=isnull(ApplyCheckCount,0)-@ApplyCheckCount");
     }
     sql.AppendLine(" where ID=@ID");
     SqlCommand comm = new SqlCommand();
     comm.Parameters.Add(SqlHelper.GetParameter("@CheckedCount", model.CheckNum));
     comm.Parameters.Add(SqlHelper.GetParameter("@PassCount", model.PassNum));
     comm.Parameters.Add(SqlHelper.GetParameter("@NotPassCount", model.NoPass));
     comm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
     if (model.FromType == "4")
     {
         comm.Parameters.Add(SqlHelper.GetParameter("@ApplyCheckCount", model.CheckNum));
     }
     comm.CommandText = sql.ToString();
     list.Add(comm);
     if (SqlHelper.ExecuteTransWithArrayList(list))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#7
0
 public static bool ConfirmBill(StorageQualityCheckReportModel model)
 {
     return CheckReportDBHelper.ConfirmBill(model);
 }
示例#8
0
 /// <summary>
 /// 取消确认
 /// </summary>
 /// <param name="model"></param>
 /// <param name="ID"></param>
 /// <returns></returns>
 public static bool UnConfirm(StorageQualityCheckReportModel model)
 {
     return CheckReportDBHelper.UnConfirm(model);
 }
        public static string GetCheckSave(StorageQualityCheckReportModel model)
        {
            string returnvalue = "00";
            #region  多次引用同个单据的时候要多其报检数量 进行校验

            #region   质检申请单不需要进行该操作
            //if (model.FromType == "1")//质检申请单时候
            //{
            //    // returnvalue = GetCheckedCount(model);
            //    SqlCommand qualitycomm = new SqlCommand();
            //    string qualitysql = "select FromType,FromBillID from officedba.QualityCheckApplyDetail where ID=@ID";
            //    qualitycomm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
            //    qualitycomm.CommandText = qualitysql;
            //    DataTable qualitydt = SqlHelper.ExecuteSearch(qualitycomm);
            //    string qualityFromType = "00";
            //    string FromBillID = "00";
            //    if (qualitydt.Rows.Count > 0)
            //    {
            //        qualityFromType = qualitydt.Rows[0]["FromType"].ToString();
            //        FromBillID = qualitydt.Rows[0]["FromBillID"].ToString();
            //    }
            //    if (qualityFromType == "1")//采购
            //    {
            //        string ProductCount = "00";
            //        string ApplyCheckCount1 = "00";
            //        SqlCommand FromPurComm = new SqlCommand();
            //        string FormPurSql = "select ProductCount as ProductCount,ApplyCheckCount as ApplyCheckCount1,(isnull(ProductCount,0)-isnull(ApplyCheckCount,0)) as ApplyCheckCount from officedba.PurchaseArriveDetail where ID=@ID";
            //        FromPurComm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
            //        FromPurComm.CommandText = FormPurSql;
            //        DataTable FromPurDt = SqlHelper.ExecuteSearch(FromPurComm);
            //        if (FromPurDt.Rows.Count > 0)
            //        {
            //            ProductCount = FromPurDt.Rows[0]["ProductCount"].ToString();//到货数量
            //            ApplyCheckCount1 = FromPurDt.Rows[0]["ApplyCheckCount1"].ToString();//已报检数量
            //            returnvalue = FromPurDt.Rows[0]["ApplyCheckCount"].ToString();//未报检数量
            //            if (ProductCount != "" && ApplyCheckCount1 != "")
            //            {
            //                if (Convert.ToDecimal(ProductCount) == Convert.ToDecimal(ApplyCheckCount1))
            //                {
            //                    returnvalue = "none";  //生产数量=已检数量
            //                }
            //            }
            //        }
            //    }
            //    if (qualityFromType == "2")//生产
            //    {
            //        string ProductedCount = "00";
            //        string CheckedCount = "00";
            //        SqlCommand FromManComm = new SqlCommand();
            //        string FormManSql = "select ProductedCount as ProductedCount,ApplyCheckCount as CheckedCount1,(isnull(ProductedCount,0)-isnull(ApplyCheckCount,0)) as CheckedCount from officedba.ManufactureTaskDetail where ID=@ID";
            //        FromManComm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
            //        FromManComm.CommandText = FormManSql;
            //        DataTable FromManDt = SqlHelper.ExecuteSearch(FromManComm);
            //        if (FromManDt.Rows.Count > 0)
            //        {
            //            ProductedCount = FromManDt.Rows[0]["ProductedCount"].ToString();
            //            CheckedCount = FromManDt.Rows[0]["CheckedCount1"].ToString();
            //            returnvalue = FromManDt.Rows[0]["CheckedCount"].ToString();
            //            if (CheckedCount != "" && ProductedCount != "")
            //            {
            //                if (Convert.ToDecimal(ProductedCount) == Convert.ToDecimal(CheckedCount))
            //                {
            //                    returnvalue = "none";
            //                }
            //            }

            //        }
            //    }
            //    if (qualityFromType == "0")//无来源
            //    {
            //        string RealCheckedCount = "00";
            //        string ProductCount = "00";
            //        SqlCommand FromNonComm = new SqlCommand();
            //        string FormNonSql = "select ProductCount from officedba.QualityCheckApplyDetail where ID=@ID";
            //        FromNonComm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
            //        FromNonComm.CommandText = FormNonSql;
            //        DataTable FromNonDt = SqlHelper.ExecuteSearch(FromNonComm);
            //        if (FromNonDt.Rows.Count > 0)
            //        {
            //            returnvalue = FromNonDt.Rows[0]["ProductCount"].ToString();
            //        }
            //    }
            //    //SqlCommand quacomm = new SqlCommand();
            //    //string quasql = "select isnull(ProductCount,0) as ProductCount,isnull(RealCheckedCount,0) as RealCheckedCount from officedba.QualityCheckApplyDetail where ID=@ID";
            //    //quacomm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
            //    //quacomm.CommandText = quasql;
            //    //DataTable quadt = SqlHelper.ExecuteSearch(quacomm);
            //    //string ProductCount = "0.00";
            //    //string RealCheckedCount = "0.00";
            //    //if (quadt.Rows.Count > 0)
            //    //{
            //    //    RealCheckedCount = quadt.Rows[0]["RealCheckedCount"].ToString();
            //    //    ProductCount = quadt.Rows[0]["ProductCount"].ToString();
            //    //}
            //    ////if(ProductCount!="" && RealCheckedCount!="")
            //    ////{
            //    ////    if (Convert.ToDecimal(ProductCount) == Convert.ToDecimal(RealCheckedCount))
            //    ////    {
            //    ////        returnvalue = "none";
            //    ////    }
            //    ////}
            //    //returnvalue = Convert.ToString(Convert.ToDecimal(ProductCount) - Convert.ToDecimal(RealCheckedCount));
            //}
            //#endregion

            //#region 无来源
            //if (model.FromType == "0")
            //{
            //    string RealCheckedCount = "00";
            //    string ProductCount = "00";
            //    SqlCommand FromNonComm = new SqlCommand();
            //    string FormNonSql = "select ProductCount from officedba.QualityCheckApplyDetail where ID=@ID";
            //    FromNonComm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
            //    FromNonComm.CommandText = FormNonSql;
            //    DataTable FromNonDt = SqlHelper.ExecuteSearch(FromNonComm);
            //    if (FromNonDt.Rows.Count > 0)
            //    {
            //        returnvalue = FromNonDt.Rows[0]["ProductCount"].ToString();
            //    }
            //}
            //#endregion

            //#region 质检报告单
            //if (model.FromType == "2")
            //{
            //    GetFromType(model.FromReportNo, model.CompanyCD);
            //    if (myFromType == "2")
            //    {
            //        GetFromType(myReportNo, model.CompanyCD);
            //    }
            //    if (myFromType != "2" && myFromType != "00")
            //    {
            //        if (int.Parse(FromDetailID) > 0)
            //        {
            //            model.FromDetailID = int.Parse(FromDetailID);
            //        }
            //        if (int.Parse(FromReportID) > 0)
            //        {
            //            model.ReportID = int.Parse(FromReportID);
            //        }
            //        if (myFromType == "1") //质检申请单
            //        {
            //            returnvalue = GetSaveCheckCount(model);
            //        }
            //        if (myFromType == "3") //生产任务单
            //        {
            //            string ProductedCount = "00";
            //            string CheckedCount = "00";
            //            SqlCommand FromManComm1 = new SqlCommand();
            //            string FormManSql1 = "select  ProductedCount,ApplyCheckCount as CheckedCount1,(isnull(ProductedCount,0)-isnull(ApplyCheckCount,0)) as CheckedCount from officedba.ManufactureTaskDetail where ID=@ID";
            //            FromManComm1.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
            //            FromManComm1.CommandText = FormManSql1;
            //            DataTable FromManDt1 = SqlHelper.ExecuteSearch(FromManComm1);
            //            if (FromManDt1.Rows.Count > 0)
            //            {
            //                ProductedCount = FromManDt1.Rows[0]["ProductedCount"].ToString();
            //                CheckedCount = FromManDt1.Rows[0]["CheckedCount1"].ToString();
            //                returnvalue = FromManDt1.Rows[0]["CheckedCount"].ToString();
            //                if (ProductedCount != "" && CheckedCount != "")
            //                {
            //                    if (Convert.ToDecimal(ProductedCount) == Convert.ToDecimal(CheckedCount))
            //                    {
            //                        returnvalue = "none";
            //                    }
            //                }
            //            }
            //        }
            //        if (myFromType == "4") //采购
            //        {
            //            string ProductCount = "00";
            //            string CheckedCount1 = "0";
            //            SqlCommand FromPurComm1 = new SqlCommand();
            //            string FormPurSql1 = "select  ProductCount,ApplyCheckCount as CheckedCount1,(isnull(ProductCount,0)-isnull(ApplyCheckCount,0)) as CheckedCount from officedba.PurchaseArriveDetail where ID=@ID";
            //            FromPurComm1.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
            //            FromPurComm1.CommandText = FormPurSql1;
            //            DataTable FromPurDt1 = SqlHelper.ExecuteSearch(FromPurComm1);
            //            if (FromPurDt1.Rows.Count > 0)
            //            {
            //                ProductCount = FromPurDt1.Rows[0]["ProductCount"].ToString();
            //                CheckedCount1 = FromPurDt1.Rows[0]["CheckedCount1"].ToString();
            //                returnvalue = FromPurDt1.Rows[0]["CheckedCount"].ToString();
            //                if (ProductCount != "" && CheckedCount1 != "")
            //                {
            //                    if (Convert.ToDecimal(ProductCount) == Convert.ToDecimal(CheckedCount1))
            //                    {
            //                        returnvalue = "none";
            //                    }
            //                }
            //            }
            //        }
            //    }
            //}
            #endregion

            #region 采购
            if (model.FromType == "4")
            {
                string ProductCount = "00";
                string CheckedCount1 = "00";
                SqlCommand FromPurComm = new SqlCommand();
                string FormPurSql = "select ProductCount as ProductCount,ApplyCheckCount as CheckedCount1,(isnull(ProductCount,0)-isnull(ApplyCheckCount,0)) as CheckedCount from officedba.PurchaseArriveDetail where ID=@ID";
                FromPurComm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                FromPurComm.CommandText = FormPurSql;
                DataTable FromPurDt = SqlHelper.ExecuteSearch(FromPurComm);
                if (FromPurDt.Rows.Count > 0)
                {
                    ProductCount = FromPurDt.Rows[0]["ProductCount"].ToString();
                    CheckedCount1 = FromPurDt.Rows[0]["CheckedCount1"].ToString();
                    returnvalue = FromPurDt.Rows[0]["CheckedCount"].ToString();
                    if (ProductCount != "" && CheckedCount1 != "")
                    {
                        if (Convert.ToDecimal(ProductCount) == Convert.ToDecimal(CheckedCount1))
                        {
                            returnvalue = "none";  //生产数量=已检数量
                        }
                    }
                }
            }
            #endregion

            #region 生产
            if (model.FromType == "3")
            {
                string ProductedCount = "00";
                string CheckedCount = "00";
                SqlCommand FromManComm = new SqlCommand();
                string FormManSql = "select ProductedCount as ProductedCount,ApplyCheckCount as CheckedCount1,(isnull(ProductedCount,0)-isnull(ApplyCheckCount,0)) as CheckedCount from officedba.ManufactureTaskDetail where ID=@ID";
                FromManComm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                FromManComm.CommandText = FormManSql;
                DataTable FromManDt = SqlHelper.ExecuteSearch(FromManComm);
                if (FromManDt.Rows.Count > 0)
                {
                    ProductedCount = FromManDt.Rows[0]["ProductedCount"].ToString();
                    CheckedCount = FromManDt.Rows[0]["CheckedCount1"].ToString();
                    returnvalue = FromManDt.Rows[0]["CheckedCount"].ToString();
                    if (CheckedCount != "" && ProductedCount != "")
                    {
                        if (Convert.ToDecimal(ProductedCount) == Convert.ToDecimal(CheckedCount))
                        {
                            returnvalue = "none";
                        }
                    }

                }
            }
            #endregion

            #endregion
            return returnvalue;
        }
示例#10
0
        /// <summary>
        /// 更新汇报单
        /// </summary>
        /// <param name="model">汇报单</param>
        /// <param name="detailList">明细</param>
        /// <param name="SortID"></param>
        /// <param name="htExtAttr">扩展属性</param>
        /// <returns></returns>
        public static bool UpdateReport(StorageQualityCheckReportModel model, List<StorageQualityCheckReportDetailModel> detailList, string[] SortID, Hashtable htExtAttr)
        {
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            try
            {

                bool succ = false;
                LogInfoModel logModel = InitLogInfo(model.ReportNo);
                logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;
                succ = CheckReportDBHelper.UpdateReport(model, detailList, SortID, htExtAttr);
                if (!succ)
                    logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                else
                    logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                LogDBHelper.InsertLog(logModel);
                return succ;
            }
            catch (Exception ex)
            {
                WriteSystemLog(userInfo, ex);
                return false;
            }
        }
        /// <summary>
        /// 结单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool CloseBill(StorageQualityCheckReportModel model, string method)
        {
            ArrayList listsql = new ArrayList();
            SqlCommand comm = new SqlCommand();
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" UPDATE officedba.QualityCheckReport SET");
            sql.AppendLine(" BillStatus              = @BillStatus,");
            sql.AppendLine(" ModifiedUserID      = @ModifiedUserID,");
            if (method == "0")
            {
                sql.AppendLine(" Closer      = @Closer,");
                sql.AppendLine(" CloseDate                = @CloseDate, ");
            }
            sql.AppendLine(" ModifiedDate                = @ModifiedDate ");
            sql.AppendLine("  Where  CompanyCD=@CompanyCD and ID=@ID");


            comm.Parameters.Add(SqlHelper.GetParameter("@ID", model.ID));
            comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
            comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
            comm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
            string BillStatus = "2";
            if (method == "0")
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@Closer", model.Closer));
                comm.Parameters.Add(SqlHelper.GetParameter("@CloseDate", model.CloseDate));
                BillStatus = "4";
            }
            comm.Parameters.Add(SqlHelper.GetParameter("@BillStatus", BillStatus));
            comm.CommandText = sql.ToString();
            listsql.Add(comm);
            if (SqlHelper.ExecuteTransWithArrayList(listsql))
            { return true; }
            else
            { return false; }
        }
        public static bool UnUpdateReport(StorageQualityCheckReportModel model)
        {
            bool returnvalue = false;
            try
            {

                GetFromType(model.FromReportNo, model.CompanyCD);
                if (myFromType == "2")
                {
                    GetFromType(myReportNo, model.CompanyCD);
                }
                if (myFromType != "2" && myFromType != "00")
                {
                    if (int.Parse(FromDetailID) > 0)
                    {
                        model.FromDetailID = int.Parse(FromDetailID);
                    }
                    if (int.Parse(FromReportID) > 0)
                    {
                        model.ReportID = int.Parse(FromReportID);
                    }
                    switch (myFromType)
                    {
                        case "1"://质检申请单
                            if (UnUpdateApply(model))
                            {
                                returnvalue = true;
                            }
                            break;
                        case "3"://生产任务单
                            if (UnUpdateManufa(model))
                            {
                                returnvalue = true;
                            }
                            break;
                        case "4"://采购
                            if (UnUpdatePur(model))
                            {
                                returnvalue = true;
                            }
                            break;
                        case "0"://无来源
                            ArrayList sqllist = new ArrayList();
                            SqlCommand noncomm = new SqlCommand();
                            string nonsql = "update officedba.QualityCheckApplyDetail set RealCheckedCount=isnull(RealCheckedCount,0)-@RealCheckedCount where ID=@ID";
                            noncomm.Parameters.Add(SqlHelper.GetParameter("@RealCheckedCount", model.CheckNum));
                            noncomm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                            noncomm.CommandText = nonsql;
                            sqllist.Add(noncomm);
                            if (SqlHelper.ExecuteTransWithArrayList(sqllist))
                            {
                                returnvalue = true;
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            catch
            { }
            myReportNo = "";
            myFromType = "";
            return returnvalue;
        }
        public static bool UnConfirm(StorageQualityCheckReportModel model)
        {
            ArrayList sqllist = new ArrayList();
            bool returnvalue = false;
            int BillTypeFlag = int.Parse(ConstUtil.BILL_TYPECODE_STORAGE_QUALITY);
            int BillTypeCode = int.Parse(ConstUtil.BILL_TYPECODE_STORAGE_REPORT);
            SqlCommand thecomm = new SqlCommand();
            string thesql = "select BillStatus from officedba.QualityCheckReport where ID=@ID";
            thecomm.Parameters.Add(SqlHelper.GetParameter("@ID", model.ID));
            thecomm.CommandText = thesql;
            string BillStatus = "0";
            DataTable theDt = SqlHelper.ExecuteSearch(thecomm);
            if (theDt.Rows.Count > 0)
            {
                BillStatus = theDt.Rows[0]["BillStatus"].ToString();
            }
            if (BillStatus == "2")
            {
                SqlCommand comm = new SqlCommand();
                string sql = " update officedba.QualityCheckReport set BillStatus='1',ModifiedUserID=@ModifiedUserID,ModifiedDate=@ModifiedDate where ID=@ID";
                comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
                comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
                comm.Parameters.Add(SqlHelper.GetParameter("@ID", model.ID));
                comm.CommandText = sql;
                sqllist.Add(comm);
                if (model.isRecheck == "0")
                {
                    switch (model.FromType)
                    {
                        case "1"://质检申请
                            UnUpdateApply(model);
                            break;
                        case "2"://质检报告
                            UnUpdateReport(model);
                            break;
                        case "3"://生产任务
                            UnUpdateManufa(model);
                            break;
                        case "4"://采购到货
                            UnUpdatePur(model);
                            break;
                        default:
                            break;
                    }
                }
                #region 撤消审批流程
                DataTable dtFlowInstance = Common.FlowDBHelper.GetFlowInstanceInfo(model.CompanyCD, BillTypeFlag, BillTypeCode, model.ID);
                if (dtFlowInstance.Rows.Count > 0)
                {
                    //提交审批了的单据
                    string FlowInstanceID = dtFlowInstance.Rows[0]["FlowInstanceID"].ToString();
                    string FlowStatus = dtFlowInstance.Rows[0]["FlowStatus"].ToString();
                    string FlowNo = dtFlowInstance.Rows[0]["FlowNo"].ToString();

                    #region 往流程任务历史记录表
                    StringBuilder sqlHis = new StringBuilder();
                    sqlHis.AppendLine("Insert into officedba.FlowTaskHistory(CompanyCD,FlowInstanceID,FlowNo,BillTypeID,BillID,StepNo,State,operateUserId,operateDate)");
                    sqlHis.AppendLine("Values(@CompanyCD,@tempFlowInstanceID,@tempFlowNo,@BillTypeFlag,@BillID,0,2,@ModifiedUserID,getdate())");


                    SqlCommand commHis = new SqlCommand();
                    commHis.CommandText = sqlHis.ToString();
                    commHis.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                    commHis.Parameters.Add(SqlHelper.GetParameter("@tempFlowInstanceID", FlowInstanceID));
                    commHis.Parameters.Add(SqlHelper.GetParameter("@tempFlowNo", FlowNo));
                    commHis.Parameters.Add(SqlHelper.GetParameter("@BillTypeFlag", BillTypeFlag));
                    commHis.Parameters.Add(SqlHelper.GetParameter("@BillID", model.ID));
                    commHis.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
                    sqllist.Add(commHis);
                    #endregion

                    #region 更新流程任务处理表
                    StringBuilder sqlTask = new StringBuilder();
                    sqlTask.AppendLine("Update officedba.FlowTaskList Set StepNo=0,ModifiedDate=getdate(),ModifiedUserID=@ModifiedUserID");
                    sqlTask.AppendLine("Where CompanyCD=@CompanyCD and FlowInstanceID=@tempFlowInstanceID");


                    SqlCommand commTask = new SqlCommand();
                    commTask.CommandText = sqlTask.ToString();
                    commTask.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                    commTask.Parameters.Add(SqlHelper.GetParameter("@tempFlowInstanceID", FlowInstanceID));
                    commTask.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
                    sqllist.Add(commTask);
                    #endregion

                    #region 更新流程实例表
                    StringBuilder sqlIns = new StringBuilder();
                    sqlIns.AppendLine("Update officedba.FlowInstance Set FlowStatus=5,ModifiedDate=getdate(),ModifiedUserID=@ModifiedUserID ");
                    sqlIns.AppendLine("Where CompanyCD=@CompanyCD ");
                    sqlIns.AppendLine("and FlowNo=@tempFlowNo ");
                    sqlIns.AppendLine("and BillTypeFlag=@BillTypeFlag ");
                    sqlIns.AppendLine("and BillTypeCode=@BillTypeCode ");
                    sqlIns.AppendLine("and BillID=@BillID");


                    SqlCommand commIns = new SqlCommand();
                    commIns.CommandText = sqlIns.ToString();
                    commIns.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                    commIns.Parameters.Add(SqlHelper.GetParameter("@tempFlowNo", FlowNo));
                    commIns.Parameters.Add(SqlHelper.GetParameter("@BillTypeFlag", BillTypeFlag));
                    commIns.Parameters.Add(SqlHelper.GetParameter("@BillTypeCode", BillTypeCode));
                    commIns.Parameters.Add(SqlHelper.GetParameter("@BillID", model.ID));
                    commIns.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
                    sqllist.Add(commIns);
                    #endregion

                }
                #endregion
            }
            else
            {
                returnvalue = false;
            }
            if (BillStatus == "2")
            {
                if (SqlHelper.ExecuteTransWithArrayList(sqllist))
                {
                    returnvalue = true;
                }
                else
                {
                    returnvalue = false;
                }
            }
            return returnvalue;

        }
        /// <summary>
        /// 报告确认
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool ConfirmBill(StorageQualityCheckReportModel model)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" UPDATE officedba.QualityCheckReport SET");
            sql.AppendLine(" Confirmor          = @Confirmor,");
            sql.AppendLine(" ConfirmDate      = @ConfirmDate,");
            sql.AppendLine(" BillStatus              = 2,");
            sql.AppendLine(" ModifiedUserID      = @ModifiedUserID,");
            sql.AppendLine(" ModifiedDate                = @ModifiedDate ");
            sql.AppendLine("  Where  CompanyCD=@CompanyCD and ID=@ID");

            SqlParameter[] param = new SqlParameter[6];
            param[0] = SqlHelper.GetParameter("@ID", model.ID);
            param[1] = SqlHelper.GetParameter("@Confirmor", model.Confirmor);
            param[2] = SqlHelper.GetParameter("@ConfirmDate", model.ConfirmDate);
            param[3] = SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID);
            param[4] = SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate);
            param[5] = SqlHelper.GetParameter("@CompanyCD", model.CompanyCD.Trim());

            SqlHelper.ExecuteTransSql(sql.ToString(), param);
            return SqlHelper.Result.OprateCount > 0 ? true : false;
        }
        public static string GetCheckConfirm(StorageQualityCheckReportModel model)
        {
            string returnvalue = "0";
            #region  多次引用同个单据的时候要多其报检数量 进行校验
            switch (model.FromType)
            {
                case "1": //质检申请单
                    SqlCommand qualitycomm = new SqlCommand();
                    string qualitysql = "select FromType,FromBillID from officedba.QualityCheckApplyDetail where ID=@ID";
                    qualitycomm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                    qualitycomm.CommandText = qualitysql;
                    DataTable qualitydt = SqlHelper.ExecuteSearch(qualitycomm);
                    string qualityFromType = "00";
                    string FromBillID = "00";
                    if (qualitydt.Rows.Count > 0)
                    {
                        qualityFromType = qualitydt.Rows[0]["FromType"].ToString();
                        FromBillID = qualitydt.Rows[0]["FromBillID"].ToString();
                    }
                    if (qualityFromType == "1")//采购
                    {
                        string ProductCount = "00";
                        string CheckedCount1 = "00";
                        SqlCommand FromPurComm = new SqlCommand();
                        string FormPurSql = "select ProductCount as ProductCount,CheckedCount as CheckedCount1,(isnull(ProductCount,0)-isnull(CheckedCount,0)) as CheckedCount from officedba.PurchaseArriveDetail where ID=@ID";
                        FromPurComm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
                        FromPurComm.CommandText = FormPurSql;
                        DataTable FromPurDt = SqlHelper.ExecuteSearch(FromPurComm);
                        if (FromPurDt.Rows.Count > 0)
                        {
                            ProductCount = FromPurDt.Rows[0]["ProductCount"].ToString();
                            CheckedCount1 = FromPurDt.Rows[0]["CheckedCount1"].ToString();
                            returnvalue = FromPurDt.Rows[0]["CheckedCount"].ToString();
                            if (ProductCount != "" && CheckedCount1 != "")
                            {
                                if (Convert.ToDecimal(ProductCount) == Convert.ToDecimal(CheckedCount1))
                                {
                                    returnvalue = "none";  //生产数量=已检数量
                                }
                            }
                        }
                    }
                    if (qualityFromType == "2")//生产
                    {
                        string ProductedCount = "00";
                        string CheckedCount = "00";
                        SqlCommand FromManComm = new SqlCommand();
                        string FormManSql = "select ProductedCount as ProductedCount,CheckedCount as CheckedCount1,(isnull(ProductedCount,0)-isnull(CheckedCount,0)) as CheckedCount from officedba.ManufactureTaskDetail where ID=@ID";
                        FromManComm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
                        FromManComm.CommandText = FormManSql;
                        DataTable FromManDt = SqlHelper.ExecuteSearch(FromManComm);
                        if (FromManDt.Rows.Count > 0)
                        {
                            ProductedCount = FromManDt.Rows[0]["ProductedCount"].ToString();
                            CheckedCount = FromManDt.Rows[0]["CheckedCount1"].ToString();
                            returnvalue = FromManDt.Rows[0]["CheckedCount"].ToString();
                            if (CheckedCount != "" && ProductedCount != "")
                            {
                                if (Convert.ToDecimal(ProductedCount) == Convert.ToDecimal(CheckedCount))
                                {
                                    returnvalue = "none";
                                }
                            }

                        }
                    }
                    if (qualityFromType == "0")
                    {
                        string RealCheckedCount = "00";
                        string ProductCount = "00";
                        SqlCommand FromNonComm = new SqlCommand();
                        string FormNonSql = "select ProductCount as ProductCount,RealCheckedCount as RealCheckedCount,(isnull(ProductCount,0)-isnull(RealCheckedCount,0)) as CheckedCount from officedba.QualityCheckApplyDetail where ID=@ID";
                        FromNonComm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                        FromNonComm.CommandText = FormNonSql;
                        DataTable FromNonDt = SqlHelper.ExecuteSearch(FromNonComm);
                        if (FromNonDt.Rows.Count > 0)
                        {
                            ProductCount = FromNonDt.Rows[0]["ProductCount"].ToString();
                            RealCheckedCount = FromNonDt.Rows[0]["RealCheckedCount"].ToString();
                            returnvalue = FromNonDt.Rows[0]["CheckedCount"].ToString();
                            if (RealCheckedCount != "" && ProductCount != "")
                            {
                                if (Convert.ToDecimal(ProductCount) == Convert.ToDecimal(RealCheckedCount))
                                {
                                    returnvalue = "none";
                                }
                            }
                        }
                    }
                    break;
                case "2": //质检报告单
                    GetFromType(model.FromReportNo, model.CompanyCD);
                    if (myFromType == "2")
                    {
                        GetFromType(myReportNo, model.CompanyCD);
                    }
                    if (myFromType != "2" && myFromType != "00")
                    {
                        if (int.Parse(FromDetailID) > 0)
                        {
                            model.FromDetailID = int.Parse(FromDetailID);
                        }
                        if (int.Parse(FromReportID) > 0)
                        {
                            model.ReportID = int.Parse(FromReportID);
                        }
                        if (myFromType == "1") //质检申请单
                        {
                            returnvalue = GetCheckedCount(model);
                        }
                        if (myFromType == "3") //生产任务单
                        {
                            string ProductedCount = "00";
                            string CheckedCount = "00";
                            SqlCommand FromManComm1 = new SqlCommand();
                            string FormManSql1 = "select  ProductedCount,CheckedCount as CheckedCount1,(isnull(ProductedCount,0)-isnull(CheckedCount,0)) as CheckedCount from officedba.ManufactureTaskDetail where ID=@ID";
                            FromManComm1.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                            FromManComm1.CommandText = FormManSql1;
                            DataTable FromManDt1 = SqlHelper.ExecuteSearch(FromManComm1);
                            if (FromManDt1.Rows.Count > 0)
                            {
                                ProductedCount = FromManDt1.Rows[0]["ProductedCount"].ToString();
                                CheckedCount = FromManDt1.Rows[0]["CheckedCount1"].ToString();
                                returnvalue = FromManDt1.Rows[0]["CheckedCount"].ToString();
                                if (ProductedCount != "" && CheckedCount != "")
                                {
                                    if (Convert.ToDecimal(ProductedCount) == Convert.ToDecimal(CheckedCount))
                                    {
                                        returnvalue = "none";
                                    }
                                }
                            }
                        }
                        if (myFromType == "4") //采购
                        {
                            string ProductCount = "00";
                            string CheckedCount1 = "0";
                            SqlCommand FromPurComm1 = new SqlCommand();
                            string FormPurSql1 = "select  ProductCount,CheckedCount as CheckedCount1,(isnull(ProductCount,0)-isnull(CheckedCount,0)) as CheckedCount from officedba.PurchaseArriveDetail where ID=@ID";
                            FromPurComm1.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                            FromPurComm1.CommandText = FormPurSql1;
                            DataTable FromPurDt1 = SqlHelper.ExecuteSearch(FromPurComm1);
                            if (FromPurDt1.Rows.Count > 0)
                            {
                                ProductCount = FromPurDt1.Rows[0]["ProductCount"].ToString();
                                CheckedCount1 = FromPurDt1.Rows[0]["CheckedCount1"].ToString();
                                returnvalue = FromPurDt1.Rows[0]["CheckedCount"].ToString();
                                if (ProductCount != "" && CheckedCount1 != "")
                                {
                                    if (Convert.ToDecimal(ProductCount) == Convert.ToDecimal(CheckedCount1))
                                    {
                                        returnvalue = "none";  //生产数量=已检数量
                                    }
                                }
                            }
                        }
                    }
                    break;
                case "4": //采购
                    string ProductCount4 = "00";
                    string CheckedCount14 = "00";
                    SqlCommand FromPurComm4 = new SqlCommand();
                    string FormPurSql4 = "select ProductCount as ProductCount,CheckedCount as CheckedCount1,(isnull(ProductCount,0)-isnull(CheckedCount,0)) as CheckedCount from officedba.PurchaseArriveDetail where ID=@ID";
                    FromPurComm4.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                    FromPurComm4.CommandText = FormPurSql4;
                    DataTable FromPurDt4 = SqlHelper.ExecuteSearch(FromPurComm4);
                    if (FromPurDt4.Rows.Count > 0)
                    {
                        ProductCount4 = FromPurDt4.Rows[0]["ProductCount"].ToString();
                        CheckedCount14 = FromPurDt4.Rows[0]["CheckedCount1"].ToString();
                        returnvalue = FromPurDt4.Rows[0]["CheckedCount"].ToString();
                        if (ProductCount4 != "" && CheckedCount14 != "")
                        {
                            if (Convert.ToDecimal(ProductCount4) == Convert.ToDecimal(CheckedCount14))
                            {
                                returnvalue = "none";  //生产数量=已检数量
                            }
                        }
                    }
                    break;
                case "3":
                    string ProductedCount3 = "00";
                    string CheckedCount3 = "00";
                    SqlCommand FromManComm3 = new SqlCommand();
                    string FormManSql3 = "select ProductedCount as ProductedCount,CheckedCount as CheckedCount1,(isnull(ProductedCount,0)-isnull(CheckedCount,0)) as CheckedCount from officedba.ManufactureTaskDetail where ID=@ID";
                    FromManComm3.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                    FromManComm3.CommandText = FormManSql3;
                    DataTable FromManDt3 = SqlHelper.ExecuteSearch(FromManComm3);
                    if (FromManDt3.Rows.Count > 0)
                    {
                        ProductedCount3 = FromManDt3.Rows[0]["ProductedCount"].ToString();
                        CheckedCount3 = FromManDt3.Rows[0]["CheckedCount1"].ToString();
                        returnvalue = FromManDt3.Rows[0]["CheckedCount"].ToString();
                        if (CheckedCount3 != "" && ProductedCount3 != "")
                        {
                            if (Convert.ToDecimal(ProductedCount3) == Convert.ToDecimal(CheckedCount3))
                            {
                                returnvalue = "none";
                            }
                        }
                    }
                    break;
                default:
                    break;
            }
            #endregion
            return returnvalue;
        }
示例#16
0
 /// <summary>
 /// 检索质检报告
 /// </summary>
 /// <param name="model"></param>
 /// <param name="BeginTime"></param>
 /// <param name="EndTime"></param>
 /// <param name="FlowStatus"></param>
 /// <param name="ReportID"></param>
 /// <returns></returns>
 public static DataTable SearchReport(StorageQualityCheckReportModel model, string BeginTime, string EndTime, string FlowStatus, string EFIndex, string EFDesc, ref int TotalCount)
 {
     return CheckReportDBHelper.GetAllReport(model, BeginTime, EndTime, FlowStatus, EFIndex, EFDesc, ref TotalCount);
 }
        /// <summary>
        /// 新增汇报单
        /// </summary>
        /// <param name="model">汇报单</param>
        /// <param name="detailList">明细</param>
        /// <param name="htExtAttr">扩展属性</param>
        /// <returns></returns>
        public static bool AddReport(StorageQualityCheckReportModel model, List<StorageQualityCheckReportDetailModel> detailList, Hashtable htExtAttr)
        {
            ArrayList sqlList = new ArrayList();
            #region 主表
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" INSERT INTO [officedba].[QualityCheckReport]                      ");
            sql.AppendLine("            ([CompanyCD]                                                   ");
            sql.AppendLine("            ,[ReportNo]                                                    ");
            sql.AppendLine("            ,[Title]                                                       ");
            sql.AppendLine("            ,[FromType]                                                    ");
            if (model.FromType != "0")
            {
                sql.AppendLine("            ,[ReportID]                                                ");
            }
            sql.AppendLine("            ,[FromLineNo]                                                  ");
            sql.AppendLine("            ,[CheckType]                                                   ");
            sql.AppendLine("            ,[CheckMode]                                                   ");
            sql.AppendLine("            ,[ProductID]                                                   ");
            sql.AppendLine("            ,[ApplyUserID]                                                 ");
            sql.AppendLine("            ,[ApplyDeptID]                                                 ");
            sql.AppendLine("            ,[Checker]                                                     ");
            sql.AppendLine("            ,[CheckDeptId]                                                 ");
            sql.AppendLine("            ,[CheckDate]                                                   ");
            if (model.Dept != 0)
            {
                sql.AppendLine(" ,DeptID");
            }
            if (model.Principal != 0)
            {
                sql.AppendLine(" ,Principal");
            }
            sql.AppendLine("             ,FromDetailID");
            if (!string.IsNullOrEmpty(model.CheckContent))
            {
                sql.AppendLine("            ,[CheckContent]                                                ");
            }
            if (!string.IsNullOrEmpty(model.CheckStandard))
            {
                sql.AppendLine("            ,[CheckStandard]                                               ");
            }
            sql.AppendLine("            ,[CheckNum]                                                    ");
            if (model.SampleNum != -99999)
            {
                sql.AppendLine("            ,[SampleNum]                                                   ");
            }
            //if (model.SampleBadNum != -99999)
            //{
            //    sql += "            ,[SampleBadNum]                                                ";
            //}
            //if (model.SamplePassNum != -99999)
            //{
            //    sql += "            ,[SamplePassNum]                                               ";
            //}
            sql.AppendLine("            ,[PassNum]                                                     ");
            sql.AppendLine("            ,[PassPercent]                                                 ");
            sql.AppendLine("            ,[NoPass]                                                      ");
            if (!string.IsNullOrEmpty(model.CheckResult))
            {
                sql.AppendLine("            ,[CheckResult]                                                 ");
            }
            sql.AppendLine("            ,[isPass]                                                      ");
            sql.AppendLine("            ,[isRecheck]                                                   ");
            if (!string.IsNullOrEmpty(model.Remark))
            {
                sql.AppendLine("            ,[Remark]                                                      ");
            }
            if (!string.IsNullOrEmpty(model.Attachment))
            {
                sql.AppendLine("            ,[Attachment]                                                  ");
            }
            sql.AppendLine("            ,[Creator]                                                     ");
            sql.AppendLine("            ,[CreateDate]                                                  ");
            sql.AppendLine("            ,[BillStatus]                                                  ");
            sql.AppendLine("            ,[ModifiedDate]                                                ");
            sql.AppendLine("            ,[ModifiedUserID]                                              ");
            if (!string.IsNullOrEmpty(model.OtherCorpName))
            {
                sql.AppendLine("            ,OtherCorpName                                                 ");
            }
            sql.AppendLine("            ,CorpBigType                                                   ");
            if (model.OtherCorpID != 0)
            {
                sql.AppendLine("            ,OtherCorpID                                                  ");
            }
            sql.AppendLine("            ,FromReportNo)                                                 ");
            sql.AppendLine("     VALUES                                                                ");
            sql.AppendLine("            (@CompanyCD                                                    ");
            sql.AppendLine("            ,@ReportNo                                                     ");
            sql.AppendLine("            ,@Title                                                        ");
            sql.AppendLine("            ,@FromType                                                     ");
            if (model.FromType != "0")
            {
                sql.AppendLine("            ,@ReportID                                                 ");
            }
            sql.AppendLine("            ,@FromLineNo                                                   ");
            sql.AppendLine("            ,@CheckType                                                    ");
            sql.AppendLine("            ,@CheckMode                                                    ");
            sql.AppendLine("            ,@ProductID                                                    ");
            sql.AppendLine("            ,@ApplyUserID                                                  ");
            sql.AppendLine("            ,@ApplyDeptID                                                  ");
            sql.AppendLine("            ,@Checker                                                      ");
            sql.AppendLine("            ,@CheckDeptId                                                   ");
            sql.AppendLine("            ,@CheckDate                                                    ");
            if (model.Dept != 0)
            {
                sql.AppendLine(" ,@DeptID");
            }
            if (model.Principal != 0)
            {
                sql.AppendLine(" ,@Principal");
            }
            sql.AppendLine("            ,@FromDetailID");

            if (!string.IsNullOrEmpty(model.CheckContent))
            {
                sql.AppendLine("            ,@CheckContent                                                 ");
            }
            if (!string.IsNullOrEmpty(model.CheckStandard))
            {
                sql.AppendLine("            ,@CheckStandard                                                ");
            }
            sql.AppendLine("            ,@CheckNum                                                     ");
            if (model.SampleNum != -99999)
            {
                sql.AppendLine("            ,@SampleNum                                                    ");
            }
            sql.AppendLine("            ,@PassNum                                                      ");
            sql.AppendLine("            ,@PassPercent                                                  ");
            sql.AppendLine("            ,@NoPass                                                       ");
            if (!string.IsNullOrEmpty(model.CheckResult))
            {
                sql.AppendLine("            ,@CheckResult                                                  ");
            }
            sql.AppendLine("            ,@isPass                                                       ");
            sql.AppendLine("            ,@isRecheck                                                    ");
            if (!string.IsNullOrEmpty(model.Remark))
            {
                sql.AppendLine("            ,@Remark                                                       ");
            }
            if (!string.IsNullOrEmpty(model.Attachment))
            {
                sql.AppendLine("            ,@Attachment                                                   ");
            }
            sql.AppendLine("            ,@Creator                                                      ");
            sql.AppendLine("            ,@CreateDate                                                   ");
            sql.AppendLine("            ,@BillStatus                                                   ");
            sql.AppendLine("            ,@ModifiedDate                                                 ");
            sql.AppendLine("            ,@ModifiedUserID                                               ");

            if (!string.IsNullOrEmpty(model.OtherCorpName))
            {
                sql.AppendLine("      ,@OtherCorpName           ");
            }
            sql.AppendLine("       ,@CorpBigType              ");
            if (model.OtherCorpID != 0)
            {
                sql.AppendLine("       ,@OtherCorpID               ");
            }
            sql.AppendLine("       ,@FromReportNo)             ");
            sql.AppendLine("set @ID=@@IDENTITY                                                         ");
            SqlParameter[] parma = new SqlParameter[1];
            SqlCommand comm = new SqlCommand();
            comm.CommandText = sql.ToString();
            comm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameter("@ReportNo", model.ReportNo));
            comm.Parameters.Add(SqlHelper.GetParameter("@Title", model.Title));
            comm.Parameters.Add(SqlHelper.GetParameter("@FromType", model.FromType));
            if (model.FromType != "0")
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@ReportID", model.ReportID));
            }
            comm.Parameters.Add(SqlHelper.GetParameter("@FromLineNo", model.FromLineNo));
            comm.Parameters.Add(SqlHelper.GetParameter("@CheckType", model.CheckType));
            comm.Parameters.Add(SqlHelper.GetParameter("@CheckMode", model.CheckMode));
            if (model.Dept != 0)
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@DeptID", model.Dept));
            }
            if (model.Principal != 0)
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@Principal", model.Principal));
            }
            comm.Parameters.Add(SqlHelper.GetParameter("@ProductID", model.ProductID));
            comm.Parameters.Add(SqlHelper.GetParameter("@ApplyUserID", model.ApplyUserID));
            comm.Parameters.Add(SqlHelper.GetParameter("@ApplyDeptID", model.ApplyDeptID));
            comm.Parameters.Add(SqlHelper.GetParameter("@Checker", model.Checker));

            comm.Parameters.Add(SqlHelper.GetParameter("@CheckDeptId", model.CheckDeptId));
            comm.Parameters.Add(SqlHelper.GetParameter("@CheckDate", model.CheckDate));
            comm.Parameters.Add(SqlHelper.GetParameter("@FromDetailID", model.FromDetailID));
            if (!string.IsNullOrEmpty(model.CheckContent))
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@CheckContent", model.CheckContent));
            }
            if (!string.IsNullOrEmpty(model.CheckStandard))
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@CheckStandard", model.CheckStandard));
            }

            comm.Parameters.Add(SqlHelper.GetParameter("@CheckNum", model.CheckNum));
            if (model.SampleNum != -99999)
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@SampleNum", model.SampleNum));
            }
            //if (model.SampleBadNum != -99999)
            //{
            //    comm.Parameters.Add(SqlHelper.GetParameter("@SampleBadNum", model.SampleBadNum));
            //}
            //if (model.SamplePassNum != -99999)
            //{
            //    comm.Parameters.Add(SqlHelper.GetParameter("@SamplePassNum", model.SamplePassNum));
            //}
            comm.Parameters.Add(SqlHelper.GetParameter("@PassNum", model.PassNum));
            comm.Parameters.Add(SqlHelper.GetParameter("@PassPercent", model.PassPercent));
            comm.Parameters.Add(SqlHelper.GetParameter("@NoPass", model.NoPass));
            comm.Parameters.Add(SqlHelper.GetParameter("@CheckResult", model.CheckResult));
            comm.Parameters.Add(SqlHelper.GetParameter("@isPass", model.isPass));
            comm.Parameters.Add(SqlHelper.GetParameter("@isRecheck", model.isRecheck));
            if (!string.IsNullOrEmpty(model.Remark))
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@Remark", model.Remark));
            }
            if (!string.IsNullOrEmpty(model.Attachment))
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@Attachment", model.Attachment));
            }
            comm.Parameters.Add(SqlHelper.GetParameter("@Creator", model.Creator));
            comm.Parameters.Add(SqlHelper.GetParameter("@CreateDate", model.CreateDate));
            comm.Parameters.Add(SqlHelper.GetParameter("@BillStatus", model.BillStatus));
            comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));

            comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
            if (!string.IsNullOrEmpty(model.OtherCorpName))
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@OtherCorpName", model.OtherCorpName));
            }
            comm.Parameters.Add(SqlHelper.GetParameter("@CorpBigType", model.CorpBigType));
            comm.Parameters.Add(SqlHelper.GetParameter("@FromReportNo", model.FromReportNo));
            if (model.OtherCorpID != 0)
            {
                comm.Parameters.Add(SqlHelper.GetParameter("@OtherCorpID", model.OtherCorpID));
            }
            comm.Parameters.Add(SqlHelper.GetOutputParameter("@ID", SqlDbType.Int));
            sqlList.Add(comm);
            // 更新扩展属性
            SqlCommand commExtAttr = UpdateExtAttr(model, htExtAttr);
            if (commExtAttr != null)
            {
                sqlList.Add(commExtAttr);
            }
            #endregion

            #region 明细Start---------
            StorageQualityCheckReportDetailModel detailmodel = new StorageQualityCheckReportDetailModel();

            if (!string.IsNullOrEmpty(model.ReportNo))
            {
                for (int i = 0; i < detailList.Count; i++)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("INSERT INTO [officedba].[CheckReportDetail]");
                    sb.AppendLine("([ReportNo],[SortNo],[CheckItem] ");
                    if (!string.IsNullOrEmpty(detailList[i].CheckValue))
                    {
                        sb.AppendLine(" ,[CheckValue]");
                    }
                    sb.AppendLine(" ,[CheckNum]");
                    if (!string.IsNullOrEmpty(detailList[i].StandardValue))
                    {
                        sb.AppendLine(",[StandardValue]");
                    }
                    sb.AppendLine(",[isPass],[Checker],[CheckDeptID],[ModifiedDate],[ModifiedUserID]");
                    if (!string.IsNullOrEmpty(detailList[i].CheckResult))
                    {
                        sb.AppendLine(",[CheckResult]");
                    }
                    if (!string.IsNullOrEmpty(detailList[i].CheckStandard))
                    {
                        sb.AppendLine(",[CheckStandard]");
                    }
                    if (!string.IsNullOrEmpty(detailList[i].LowerLimit))
                    {
                        sb.AppendLine(",[LowerLimit]");
                    }
                    if (!string.IsNullOrEmpty(detailList[i].NormUpLimit))
                    {
                        sb.AppendLine(",[NormUpLimit]");
                    }
                    if (!string.IsNullOrEmpty(detailList[i].Remark))
                    {
                        sb.AppendLine(",[Remark]");
                    }
                    if (detailList[i].PassNum != -1)
                    {

                        sb.AppendLine(",[PassNum]");
                    }
                    if (detailList[i].NotPassNum != -1)
                    {
                        sb.AppendLine(",[NotPassNum]");
                    }
                    //if (detailList[i].BadNum != -1)
                    //{
                    //    sb.AppendLine(",[BadNum]");
                    //}
                    sb.AppendLine(" ,[CompanyCD])");
                    sb.AppendLine("  values(");
                    sb.AppendLine(" @ReportNo,@SortNo,@CheckItem");
                    if (!string.IsNullOrEmpty(detailList[i].CheckValue))
                    {
                        sb.AppendLine(",@CheckValue");
                    }
                    sb.AppendLine(",@CheckNum");
                    if (!string.IsNullOrEmpty(detailList[i].StandardValue))
                    {
                        sb.AppendLine(",@StandardValue");
                    }
                    sb.AppendLine(",@isPass,@Checker,@CheckDeptID,@ModifiedDate,@ModifiedUserID");
                    if (!string.IsNullOrEmpty(detailList[i].CheckResult))
                    {
                        sb.AppendLine("         ,@CheckResult");
                    }
                    if (!string.IsNullOrEmpty(detailList[i].CheckStandard))
                    {
                        sb.AppendLine("            ,@CheckStandard");
                    }
                    if (!string.IsNullOrEmpty(detailList[i].LowerLimit))
                    {
                        sb.AppendLine("           ,@LowerLimit");
                    }
                    if (!string.IsNullOrEmpty(detailList[i].NormUpLimit))
                    {
                        sb.AppendLine("            ,@NormUpLimit");
                    }
                    if (!string.IsNullOrEmpty(detailList[i].Remark))
                    {
                        sb.AppendLine("       , @Remark");
                    }
                    if (detailList[i].PassNum != -1)
                    {
                        sb.AppendLine("               ,@PassNum");
                    }
                    if (detailList[i].NotPassNum != -1)
                    {
                        sb.AppendLine("           ,@NotPassNum");
                    }
                    //if (detailList[i].BadNum != -1)
                    //{
                    //    sb.AppendLine("                ,@BadNum");
                    //}
                    sb.AppendLine("  ,@CompanyCD)");
                    SqlCommand sqlcomm = new SqlCommand();
                    sqlcomm.CommandText = sb.ToString();
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@ReportNo", model.ReportNo));
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@SortNo", detailList[i].SortNo));
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckItem", detailList[i].CheckItem));
                    if (!string.IsNullOrEmpty(detailList[i].CheckValue))
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckValue", detailList[i].CheckValue));
                    }
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckNum", detailList[i].CheckNum));
                    if (!string.IsNullOrEmpty(detailList[i].StandardValue))
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@StandardValue", detailList[i].StandardValue));
                    }
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@isPass", detailList[i].isPass));
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@Checker", detailList[i].Checker));
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckDeptID", detailList[i].CheckDeptID));
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
                    if (!string.IsNullOrEmpty(detailList[i].CheckResult))
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckResult", detailList[i].CheckResult));
                    }
                    if (!string.IsNullOrEmpty(detailList[i].CheckStandard))
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CheckStandard", detailList[i].CheckStandard));
                    }
                    if (!string.IsNullOrEmpty(detailList[i].LowerLimit))
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@LowerLimit", detailList[i].LowerLimit));
                    }
                    if (!string.IsNullOrEmpty(detailList[i].NormUpLimit))
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@NormUpLimit", detailList[i].NormUpLimit));
                    }
                    if (!string.IsNullOrEmpty(detailList[i].Remark))
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@Remark", detailList[i].Remark));
                    }
                    if (detailList[i].PassNum != -1)
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@PassNum", detailList[i].PassNum));
                    }
                    if (detailList[i].NotPassNum != -1)
                    {
                        sqlcomm.Parameters.Add(SqlHelper.GetParameter("@NotPassNum", detailList[i].NotPassNum));
                    }
                    //if (detailList[i].BadNum != -1)
                    //{
                    //    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@BadNum", detailList[i].BadNum));
                    //}
                    sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                    sqlList.Add(sqlcomm);

                }

            }
            #endregion
            if (SqlHelper.ExecuteTransWithArrayList(sqlList))
            {
                return true;
            }
            else
            {
                return false;
            }

        }
示例#18
0
 /// <summary>
 /// 获取报告单明细详细信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static DataTable GetReportDetailInfo(StorageQualityCheckReportModel model)
 {
     try
     {
         return CheckReportDBHelper.GetReportDetailInfo(model);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
 public static string GetSaveCheckCount(StorageQualityCheckReportModel model)
 {
     string returnvalue = "0";
     SqlCommand checkcomm = new SqlCommand();
     string FromType = "0";
     string FromBillID = "0";
     string checksql = "select FromType,FromBillID from officedba.QualityCheckApplyDetail where ID=@ID";
     checkcomm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
     checkcomm.CommandText = checksql;
     DataTable dt = SqlHelper.ExecuteSearch(checkcomm);
     if (dt.Rows.Count > 0)
     {
         FromType = dt.Rows[0]["FromType"].ToString();
         FromBillID = dt.Rows[0]["FromBillID"].ToString();
     }
     switch (FromType)
     {
         case "0":
             SqlCommand FromNonComm = new SqlCommand();
             string FormNonSql = "select ProductCount as ProductCount from officedba.QualityCheckApplyDetail where ID=@ID";
             FromNonComm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
             FromNonComm.CommandText = FormNonSql;
             DataTable FromNonDt = SqlHelper.ExecuteSearch(FromNonComm);
             if (FromNonDt.Rows.Count > 0)
             {
                 returnvalue = FromNonDt.Rows[0]["ProductCount"].ToString();
             }
             break;
         case "1"://源单为采购时候
             string RealCheckedCount1 = "00";
             string ProductCount1 = "00";
             SqlCommand purcomm = new SqlCommand();
             string pursql = "select ProductCount as ProductCount,ApplyCheckCount as CheckedCount1,(isnull(ProductCount,0)-isnull(ApplyCheckCount,0)) as CheckedCount from officedba.PurchaseArriveDetail where ID=@ID";
             purcomm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
             purcomm.CommandText = pursql;
             DataTable purdt = SqlHelper.ExecuteSearch(purcomm);
             if (purdt.Rows.Count > 0)
             {
                 ProductCount1 = purdt.Rows[0]["ProductCount"].ToString();// 到货数量
                 RealCheckedCount1 = purdt.Rows[0]["CheckedCount1"].ToString();//已检数量
                 returnvalue = purdt.Rows[0]["CheckedCount"].ToString();//未检数量
                 if (RealCheckedCount1 != "" && ProductCount1 != "")
                 {
                     if (Convert.ToDecimal(ProductCount1) == Convert.ToDecimal(RealCheckedCount1))
                     {
                         returnvalue = "none";
                     }
                 }
             }
             break;
         case "2"://源单为生产
             string RealCheckedCount2 = "00";
             string ProductCount2 = "00";
             SqlCommand mancomm = new SqlCommand();
             string mansql = "select ProductedCount as ProductedCount,ApplyCheckCount as CheckedCount1,(isnull(ProductedCount,0)-isnull(ApplyCheckCount,0)) as CheckedCount from officedba.ManufactureTaskDetail where ID=@ID";
             mancomm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
             mancomm.CommandText = mansql;
             DataTable mandt = SqlHelper.ExecuteSearch(mancomm);
             if (mandt.Rows.Count > 0)
             {
                 ProductCount2 = mandt.Rows[0]["ProductedCount"].ToString();
                 RealCheckedCount2 = mandt.Rows[0]["CheckedCount1"].ToString();
                 returnvalue = mandt.Rows[0]["CheckedCount"].ToString();
                 if (RealCheckedCount2 != "" && ProductCount2 != "")
                 {
                     if (Convert.ToDecimal(ProductCount2) == Convert.ToDecimal(RealCheckedCount2))
                     {
                         returnvalue = "none";
                     }
                 }
             }
             break;
         default:
             break;
     }
     return returnvalue;
 }
示例#20
0
 /// <summary>
 /// 回写生产任务
 /// </summary>
 /// <param name="model"></param>
 /// <param name="ID"></param>
 /// <returns></returns>
 public static bool UpdateMan(StorageQualityCheckReportModel model)
 {
     return CheckReportDBHelper.UpdateManufa(model);
 }
        /// <summary>
        /// 扩展属性更新命令
        /// </summary>
        /// <param name="model">质检汇报单</param>
        /// <param name="htExtAttr">扩展属性</param>
        /// <returns></returns>
        public static SqlCommand UpdateExtAttr(StorageQualityCheckReportModel model, Hashtable htExtAttr)
        {
            SqlCommand sqlcomm = new SqlCommand();
            if (htExtAttr == null || htExtAttr.Count < 1)
            {// 没有属性需要修改
                return null;
            }

            StringBuilder sb = new StringBuilder(" UPDATE officedba.QualityCheckReport SET ");
            foreach (DictionaryEntry de in htExtAttr)// fileht为一个Hashtable实例
            {
                sb.AppendFormat(" {0}=@{0},", de.Key.ToString());
                sqlcomm.Parameters.Add(SqlHelper.GetParameter(String.Format("@{0}", de.Key.ToString()), de.Value));
            }
            string strSql = sb.ToString();
            strSql = strSql.TrimEnd(',');
            strSql += " WHERE CompanyCD = @CompanyCD  AND ReportNo = @ReportNo ";
            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@ReportNo", model.ReportNo));
            sqlcomm.CommandText = strSql;

            return sqlcomm;
        }
示例#22
0
 public static bool CloseBill(StorageQualityCheckReportModel model, string method)
 {
     return CheckReportDBHelper.CloseBill(model, method);
 }
 /// <summary>
 /// 回写质检报告
 /// </summary>
 /// <param name="model"></param>
 /// <param name="ID"></param>
 /// <returns></returns>
 public static bool UpdateReport(StorageQualityCheckReportModel model)
 {
     bool returnvalue = false;
     try
     {
         GetFromType(model.FromReportNo, model.CompanyCD);
         if (myFromType == "2")
         {
             GetFromType(myReportNo, model.CompanyCD);
         }
         if (myFromType != "2" && myFromType != "00")
         {
             if (int.Parse(FromDetailID) > 0)
             {
                 model.FromDetailID = int.Parse(FromDetailID);
             }
             if (int.Parse(FromReportID) > 0)
             {
                 model.ReportID = int.Parse(FromReportID);
             }
             switch (myFromType)
             {
                 case "1": //申请单
                     if (UpdateApply(model))
                     {
                         returnvalue = true;
                     }
                     else
                     { returnvalue = false; }
                     break;
                 case "3"://生产
                     if (UpdateManufa(model))
                     {
                         returnvalue = true;
                     }
                     else
                     { returnvalue = false; }
                     break;
                 case "4"://采购
                     if (UpdatePur(model))
                     {
                         returnvalue = true;
                     }
                     else
                     { returnvalue = false; }
                     break;
                 default:
                     break;
             }
         }
     }
     catch
     { }
     myReportNo = "";
     myFromType = "";
     return returnvalue;
 }
示例#24
0
 /// <summary>
 /// 确认回写时候 判断已检数量和报检数量
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static string CheckConfirm(StorageQualityCheckReportModel model)
 {
     return CheckReportDBHelper.GetCheckConfirm(model);
 }
        public static DataTable GetReportInfo(StorageQualityCheckReportModel model)
        {
            #region 查询语句
            //查询SQL拼写
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" SELECT     q.ID,q.ReportNo, q.Title, isnull(q.OtherCorpName,'') as OtherCorpName,isnull(q.OtherCorpID,0) as OtherCorpID,isnull(q.ReportName,'') as ReportName,isnull(CONVERT(varchar,q.CreateDate,120),'') as CreateDate,isnull(q.FromReportNo,'') as FromReportNo,isnull(q.CorpBigType,'0') as CorpBigType,                                                                        ");
            sql.AppendLine("       Replace(q.[Attachment],'\\',',') as Attachment,isnull(q.FromDetailID,0) as FromDetailID,  ");
            sql.AppendLine(" CASE CorpBigType WHEN '1' THEN '客户' WHEN '2' THEN '供应商' WHEN '3' THEN '竞争对手' WHEN '4' THEN '银行' WHEN '5' THEN '外协加工厂'                                                                           ");
            sql.AppendLine(" WHEN   '6' THEN '运输商' WHEN '7' THEN '其他' END AS BigTypeName,       q.FromType,    q.CheckMode,  q.CheckType,isnull(CONVERT(varchar,q.CheckDate,120),'') as CheckDate,                                                                 ");
            sql.AppendLine(" (select EmployeeName from officedba.EmployeeInfo where officedba.EmployeeInfo.ID=q.Checker) as  EmployeeName ,                                                    ");
            sql.AppendLine(" CASE q.BillStatus WHEN '1' THEN '制单' WHEN '2' THEN '执行' WHEN '3' THEN '变更' WHEN '4' THEN '手工结单' WHEN '5' THEN '自动结单' END AS BillStatus,                                                           ");
            sql.AppendLine(" (select DeptName from officedba.DeptInfo where officedba.DeptInfo.ID=q.ApplyDeptID) as ApplyDeptIDName,                                                                                                         ");
            sql.AppendLine(" (select EmployeeName from officedba.EmployeeInfo where officedba.EmployeeInfo.ID=q.ApplyUserID) as ApplyUserIDName,                                                                                             ");
            sql.AppendLine(" q.FromType, q.ReportID,isnull(q.FromLineNo,'0') as FromLineNo, q.ProductID, isnull(q.ApplyUserID,0) as ApplyUserID,isnull(q.ApplyDeptID,0) as ApplyDeptID,isnull(q.Checker,0) as Checker,isnull(q.CheckDeptId,0) as CheckDeptId,                                                               ");
            sql.AppendLine(" isnull(q.CheckContent,'') as CheckContent,isnull(q.CheckStandard,'') as CheckStandard,convert(numeric(12,2),isnull(q.CheckNum,0)) as CheckNum,convert(numeric(12,2),isnull(q.SampleNum,0)) as SampleNum,convert(numeric(12,2),isnull(q.PassNum,0)) as PassNum,                                                                                                           ");
            sql.AppendLine(" (select EmployeeName from officedba.EmployeeInfo where officedba.EmployeeInfo.ID=q.Creator) as CreatorName,   (select EmployeeName from officedba.EmployeeInfo where officedba.EmployeeInfo.ID=q.Closer) as CloserName,              ");
            sql.AppendLine(" (q.ModifiedUserID) as ModifiedUserIDName,           ");
            sql.AppendLine(" (select ProductName from officedba.ProductInfo where officedba.ProductInfo.ID=q.ProductID) as ProductName,");
            sql.AppendLine(" (select ProdNo from officedba.ProductInfo where officedba.ProductInfo.ID=q.ProductID) as ProdNo,");
            sql.AppendLine(" (select UnitID from officedba.ProductInfo where officedba.ProductInfo.ID=q.ProductID) as UnitID,");
            sql.AppendLine(" (select CodeName from officedba.CodeUnitType where officedba.CodeUnitType.ID=(select UnitID from officedba.ProductInfo where officedba.ProductInfo.ID=q.ProductID)) as CodeName, ");
            sql.AppendLine(" (select DeptName from officedba.DeptInfo where officedba.DeptInfo.ID=q.CheckDeptId) as DeptName,");
            sql.AppendLine(" (select EmployeeName from officedba.EmployeeInfo where officedba.EmployeeInfo.ID=q.Confirmor) as ConfirmorName,convert(numeric(12,2),isnull(q.PassPercent,0)) as PassPercent,convert(numeric(12,2),isnull(q.NoPass,0)) as NoPass, q.CheckResult, q.isPass, q.isRecheck,                                 ");
            sql.AppendLine(" isnull(q.Remark,'') as Remark,q.Creator,q.Confirmor,isnull(CONVERT(varchar,q.ConfirmDate,120),'') as ConfirmDate,q.Closer,isnull(CONVERT(varchar,q.CloseDate,120),'') as CloseDate,isnull(CONVERT(varchar,q.ModifiedDate,120),'') as ModifiedDate,q.ModifiedUserID,q.BillStatus as BillStatusID,isnull(q.Principal,0)as Principal,isnull(q.DeptID,0) as TheDeptID, ");
            sql.AppendLine(" (select Specification from officedba.ProductInfo where officedba.ProductInfo.ID=q.ProductID) as Specification, ");
            sql.AppendLine(" (select DeptName from officedba.DeptInfo where officedba.DeptInfo.ID=q.DeptID) as TheDeptName,");
            sql.AppendLine(" (select EmployeeName from officedba.EmployeeInfo where officedba.EmployeeInfo.ID=q.Principal) as PrincipalName, ");
            sql.AppendLine(" q.ExtField1,q.ExtField2,q.ExtField3,q.ExtField4,q.ExtField5,q.ExtField6,q.ExtField7,q.ExtField8,q.ExtField9,q.ExtField10 ");
            sql.AppendLine(" FROM         officedba.QualityCheckReport AS q                                                                             ");
            sql.AppendLine("  where q.CompanyCD=@CompanyCD and q.ID=@ID ");

            #endregion

            //定义查询的命令
            SqlCommand comm = new SqlCommand();
            //添加公司代码参数
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", model.ID.ToString()));


            //指定命令的SQL文
            comm.CommandText = sql.ToString();
            //执行查询
            return SqlHelper.ExecuteSearch(comm);
        }
        /// <summary>
        /// 检索需要
        /// </summary>
        /// <param name="model"></param>
        /// <param name="BeginTime"></param>
        /// <param name="EndTime"></param>
        /// <param name="FlowStatus"></param>
        /// <returns></returns>
        public static DataTable GetAllReport(StorageQualityCheckReportModel model, string BeginTime, string EndTime, string FlowStatus, string EFIndex, string EFDesc, ref int TotalCount)
        {
            int BillTypeFlag = int.Parse(ConstUtil.BILL_TYPECODE_STORAGE_QUALITY);
            int BillTypeCode = int.Parse(ConstUtil.BILL_TYPECODE_STORAGE_REPORT);
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("select * from ( ");
            sql.AppendLine(" SELECT     q.ReportNo,q.ModifiedDate,q.Title,isnull(q.OtherCorpName,'') as OtherCorpName,isnull(d.DeptName,'') as DeptName,q.BillStatus as BillStatusID,  ");
            sql.AppendLine("                       CASE CorpBigType WHEN '1' THEN '客户' WHEN '2' THEN '供应商' WHEN '3' THEN '竞争对手' WHEN '4' THEN '银行' WHEN '5' THEN '外协加工厂' WHEN '6' THEN '运输商' WHEN '7' THEN '其他' ELSE '' END AS BigTypeName,    ");
            sql.AppendLine("                       CASE FromType WHEN '0' THEN '无来源' WHEN '1' THEN '质检申请单' WHEN '2' THEN '质检报告单' WHEN '3' THEN '生产任务单' WHEN '4' THEN '采购到货单' ELSE '' END AS FromTypeName,                                ");
            sql.AppendLine("                       CASE CheckMode WHEN '1' THEN '全检' WHEN '2' THEN '抽检' WHEN '3' THEN '临检' ELSE '空' END AS CheckModeName, ");
            sql.AppendLine("                       CASE CheckType WHEN '1' THEN '进货检验' WHEN '2' THEN '过程检验' WHEN '3' THEN '最终检验' ELSE '' END AS CheckTypeName,isnull(e.EmployeeName,'') as EmployeeName, ");
            sql.AppendLine("                       CASE f.FlowStatus WHEN '1' THEN '待审批' WHEN '2' THEN '审批中' WHEN '3' THEN '审批通过' WHEN '4' THEN '审批不通过' when '5' then '撤消审批' ELSE '' END AS FlowStatus,isnull(f.FlowStatus,'0') as FlowStatusID, ");
            sql.AppendLine("                       CASE q.BillStatus WHEN '1' THEN '制单' WHEN '2' THEN '执行' WHEN '3' THEN '变更' WHEN '4' THEN '手工结单' WHEN '5' THEN '自动结单' ELSE '' END AS BillStatus, ");
            sql.AppendLine("                       isnull(substring(CONVERT(varchar,q.CheckDate,120),0,11),'') as CheckDate, q.ID ");
            sql.AppendLine(" FROM         officedba.QualityCheckReport AS q LEFT  JOIN ");
            sql.AppendLine("                       officedba.FlowInstance AS f ON q.CompanyCD = f.CompanyCD AND f.BillTypeFlag = " + BillTypeFlag + " AND f.BillTypeCode =" + BillTypeCode + " AND ");
            sql.AppendLine("                       q.ID = f.BillID  ");
            sql.AppendLine("   and f.ID=(select max(ID) from officedba.FlowInstance where q.CompanyCD = officedba.FlowInstance.CompanyCD AND officedba.FlowInstance.BillTypeFlag = " + BillTypeFlag + " AND officedba.FlowInstance.BillTypeCode = " + BillTypeCode + " AND  q.ID = officedba.FlowInstance.BillID) ");
            sql.AppendLine("              LEFT JOIN     officedba.EmployeeInfo AS e ON q.ApplyUserID = e.ID LEFT  JOIN ");
            sql.AppendLine("                       officedba.DeptInfo AS d ON q.ApplyDeptID = d.ID ");
            sql.AppendLine(" where q.CompanyCD=@CompanyCD  ");
            SqlCommand comm = new SqlCommand();
            comm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
            if (!string.IsNullOrEmpty(model.ReportNo))
            {
                sql.AppendLine(" and q.ReportNo like @ReportNo");
                comm.Parameters.Add(SqlHelper.GetParameter("@ReportNo", "%" + model.ReportNo + "%"));
            }
            if (!string.IsNullOrEmpty(model.Title))
            {
                sql.AppendLine(" and q.Title like @Title");
                comm.Parameters.Add(SqlHelper.GetParameter("@Title", "%" + model.Title + "%"));
            }
            if (model.Checker > 0)
            {
                sql.AppendLine(" and q.ApplyUserID=@Checker");
                comm.Parameters.Add(SqlHelper.GetParameter("@Checker", model.Checker));

            }
            if (!string.IsNullOrEmpty(model.FromReportNo))
            {
                sql.AppendLine(" and q.FromReportNo like @FromReportNo");
                comm.Parameters.Add(SqlHelper.GetParameter("@FromReportNo", "%" + model.FromReportNo + "%"));
            }
            if (model.ApplyDeptID > 0)
            {
                sql.AppendLine(" and q.ApplyDeptID=@ApplyDeptID");
                comm.Parameters.Add(SqlHelper.GetParameter("@ApplyDeptID", model.ApplyDeptID));
            }
            if (!string.IsNullOrEmpty(BeginTime))
            {
                sql.AppendLine(" and q.CheckDate>=@BeginTime");
                comm.Parameters.Add(SqlHelper.GetParameter("@BeginTime", BeginTime));
            }
            if (!string.IsNullOrEmpty(EndTime))
            {
                sql.AppendLine(" and q.CheckDate<=@EndTime");
                comm.Parameters.Add(SqlHelper.GetParameter("@EndTime", EndTime));
            }

            if (!string.IsNullOrEmpty(EFIndex) && !string.IsNullOrEmpty(EFDesc))
            {
                sql.AppendLine(" and q.ExtField" + EFIndex + " LIKE @EFDesc ");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@EFDesc", "%" + EFDesc + "%"));
            }

            if (model.FromType != "00")
            {
                sql.AppendLine(" and q.FromType=@FromType");
                comm.Parameters.Add(SqlHelper.GetParameter("@FromType", model.FromType));
            }
            if (model.CheckType != "00")
            {
                sql.AppendLine(" and q.CheckType=@CheckType");
                comm.Parameters.Add(SqlHelper.GetParameter("@CheckType", model.CheckType));
            }
            if (model.BillStatus != "00")
            {
                sql.AppendLine(" and q.BillStatus=@BillStatus");
                comm.Parameters.Add(SqlHelper.GetParameter("@BillStatus", model.BillStatus));
            }
            if (model.CheckMode != "00")
            {
                sql.AppendLine(" and q.CheckMode=@CheckMode");
                comm.Parameters.Add(SqlHelper.GetParameter("@CheckMode", model.CheckMode));
            }
            if (model.ApplyUserID > 0)
            {

                sql.AppendLine(" and q.ApplyUserID=@ApplyUserID");
                comm.Parameters.Add(SqlHelper.GetParameter("@ApplyUserID", model.ApplyUserID));
            }
            if (FlowStatus != "00" && FlowStatus != "6")
            {
                sql.AppendLine(" and f.FlowStatus=@FlowStatus");
                comm.Parameters.Add(SqlHelper.GetParameter("@FlowStatus", FlowStatus));
            }
            sql.AppendLine(" ) as Info ");
            if (FlowStatus == "6")
            {
                sql.AppendLine(" where  FlowStatusID=@FlowStatus1");
                comm.Parameters.Add(SqlHelper.GetParameter("@FlowStatus1", "0"));
            }
            if (model.Creator == -100)
            {
                sql.AppendLine(" order by " + model.Attachment);
            }
            comm.CommandText = sql.ToString();
            DataTable dt = new DataTable();
            if (model.Creator == -100)
            {
                dt = SqlHelper.ExecuteSearch(comm);
            }
            else
            {
                dt = SqlHelper.PagerWithCommand(comm, model.Creator, model.Confirmor, model.Attachment, ref TotalCount);
            }
            return dt;
        }
        //public static bool UnUpdateApply(StorageQualityCheckReportModel model)
        //{
        //    ArrayList sqllist = new ArrayList();
        //    SqlCommand quacomm=new SqlCommand

        //    string sql = "";
        //    sql = "update officedba.QualityCheckApplyDetail set CheckedCount=isnull(CheckedCount,0)-@CheckedCount,PassCount=isnull(PassCount,0)-@PassCount,NotPassCount=isnull(NotPassCount,0)-@NotPassCount where  ID=@ID";
        //    SqlCommand comm = new SqlCommand();
        //    comm.CommandText = sql;
        //    comm.Parameters.Add(SqlHelper.GetParameter("@CheckedCount", model.CheckNum));
        //    comm.Parameters.Add(SqlHelper.GetParameter("@PassCount", model.PassNum));
        //    comm.Parameters.Add(SqlHelper.GetParameter("@NotPassCount", model.NoPass));
        //    comm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
        //    sqllist.Add(comm);
        //    if (SqlHelper.ExecuteTransWithArrayList(sqllist))
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
        public static bool UnUpdateApply(StorageQualityCheckReportModel model)
        {
            ArrayList sqllist = new ArrayList();
            string sql = "";
            sql = "update officedba.QualityCheckApplyDetail set RealCheckedCount=isnull(RealCheckedCount,0)-@ProductCount where  ID=@ID";
            SqlCommand comm = new SqlCommand();
            comm.CommandText = sql;
            comm.Parameters.Add(SqlHelper.GetParameter("@ProductCount", model.CheckNum));
            comm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
            sqllist.Add(comm);
            #region 回写质检申请单源单类型的相应数据
            SqlCommand SelComm = new SqlCommand();
            string selsql = "select FromType from officedba.QualityCheckApplay where ID=@ID";
            SelComm.Parameters.Add(SqlHelper.GetParameter("@ID", model.ReportID));
            SelComm.CommandText = selsql;
            string Fromtype = "00";
            DataTable seldt = SqlHelper.ExecuteSearch(SelComm);
            if (seldt.Rows.Count > 0)
            {
                Fromtype = seldt.Rows[0]["FromType"].ToString();
            }

            if (Fromtype == "1") //质检申请单的源单类型为 采购时
            {
                #region 根据源单明细ID 获取采购或生产明细ID
                SqlCommand GetDetailComm = new SqlCommand();
                string GetDetailSql = "select FromBillID from officedba.QualityCheckApplyDetail where ID=@ID";
                GetDetailComm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                GetDetailComm.CommandText = GetDetailSql;
                DataTable GetDetailDt = SqlHelper.ExecuteSearch(GetDetailComm);
                string FromBillID = "0";
                if (GetDetailDt.Rows.Count > 0)
                {
                    FromBillID = GetDetailDt.Rows[0]["FromBillID"].ToString();
                }
                #endregion
                if (int.Parse(FromBillID) > 0)
                {
                    SqlCommand purcomm = new SqlCommand();
                    string pursql = " update  officedba.PurchaseArriveDetail set CheckedCount=isnull(CheckedCount,0)-@CheckedCount,PassCount=isnull(PassCount,0)-@PassCount,NotPassCount=isnull(NotPassCount,0)-@NotPassCount";
                    pursql += " where ID=@ID";
                    purcomm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
                    purcomm.Parameters.Add(SqlHelper.GetParameter("@CheckedCount", model.CheckNum));
                    purcomm.Parameters.Add(SqlHelper.GetParameter("@PassCount", model.PassNum));
                    purcomm.Parameters.Add(SqlHelper.GetParameter("@NotPassCount", model.NoPass));
                    purcomm.CommandText = pursql;
                    sqllist.Add(purcomm);
                }
            }
            if (Fromtype == "2") //质检申请单的源单类型为 生产
            {
                #region 根据源单明细ID 获取采购或生产明细ID
                SqlCommand GetDetailComm = new SqlCommand();
                string GetDetailSql = "select FromBillID from officedba.QualityCheckApplyDetail where ID=@ID";
                GetDetailComm.Parameters.Add(SqlHelper.GetParameter("@ID", model.FromDetailID));
                GetDetailComm.CommandText = GetDetailSql;
                DataTable GetDetailDt = SqlHelper.ExecuteSearch(GetDetailComm);
                string FromBillID = "0";
                if (GetDetailDt.Rows.Count > 0)
                {
                    FromBillID = GetDetailDt.Rows[0]["FromBillID"].ToString();
                }
                #endregion
                if (int.Parse(FromBillID) > 0)
                {
                    SqlCommand mancomm = new SqlCommand();
                    string mansql = " update  officedba.ManufactureTaskDetail set CheckedCount=isnull(CheckedCount,0)-@CheckedCount,PassCount=isnull(PassCount,0)-@PassCount,NotPassCount=isnull(NotPassCount,0)-@NotPassCount";
                    mansql += " where ID=@ID";
                    mancomm.Parameters.Add(SqlHelper.GetParameter("@ID", FromBillID));
                    mancomm.Parameters.Add(SqlHelper.GetParameter("@CheckedCount", model.CheckNum));
                    mancomm.Parameters.Add(SqlHelper.GetParameter("@PassCount", model.PassNum));
                    mancomm.Parameters.Add(SqlHelper.GetParameter("@NotPassCount", model.NoPass));
                    mancomm.CommandText = mansql;
                    sqllist.Add(mancomm);
                }
            }
            #endregion
            if (SqlHelper.ExecuteTransWithArrayList(sqllist))
            {
                return true;
            }
            else
            {
                return false;
            }
        }