예제 #1
0
        /// <summary>
        /// 插入红冲入库和红冲入库明细
        /// </summary>
        /// <param name="model"></param>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public static bool InsertStorageInRed(StorageInRedModel model, List<StorageInRedDetailModel> modelList, Hashtable htExtAttr, out int IndexIDentity)
        {
            IndexIDentity = 0;
            //获取登陆用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //设置公司代码
            model.CompanyCD = userInfo.CompanyCD;
            //定义返回变量
            bool isSucc = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            //获取公司代码
            string companyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;

            //执行删除操作
            try
            {
                //执行更新
                isSucc = StorageInRedDBHelper.InsertStorageInRed(model, modelList, out IndexIDentity, htExtAttr);

            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }
            //定义变量
            string remark;
            //成功时
            if (isSucc)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }
            //操作日志
            LogInfoModel logModel = InitLogInfo(model.InNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_INSERT;
            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);
            return isSucc;
        }
 /// <summary>
 /// 获取入库单列表
 /// </summary>
 /// <param name="companycd"></param>
 /// <returns></returns>
 public static DataTable GetStorageInList(StorageInRedModel model, string InType)
 {
     string sql = string.Empty;
     switch (InType)
     {
         case "1":
             {
                 sql = "select ID,'采购入库单' as FromType,InNo,Title,CountTotal,ISNULL(CONVERT(VARCHAR(10),CreateDate,21),'') AS CreateDate from officedba.StorageInPurchase where CompanyCD='" + model.CompanyCD + "' and BillStatus=2";
             }
             break;
         case "2":
             {
                 sql = "select ID,'生产完工入库单' as FromType,InNo,Title,CountTotal,ISNULL(CONVERT(VARCHAR(10),CreateDate,21),'') AS CreateDate from officedba.StorageInProcess where CompanyCD='" + model.CompanyCD + "' and BillStatus=2";
             }
             break;
         case "3":
             {
                 sql = "select ID,'其他入库单' as FromType,InNo,Title,CountTotal,ISNULL(CONVERT(VARCHAR(10),CreateDate,21),'') AS CreateDate from officedba.StorageInOther where CompanyCD='" + model.CompanyCD + "' and BillStatus=2";
             }
             break;
         default:
             break;
     }
     SqlCommand comm = new SqlCommand();
     //添加公司代码参数
     if (!string.IsNullOrEmpty(model.InNo))
     {
         sql += " and InNo like '%'+ @InNo +'%'";
         comm.Parameters.Add(SqlHelper.GetParameterFromString("@InNo", model.InNo));
     }
     if (!string.IsNullOrEmpty(model.Title))
     {
         sql += " and Title like '%'+ @Title +'%'";
         comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title", model.Title));
     }
     comm.CommandText = sql;
     return SqlHelper.ExecuteSearch(comm);
 }
        public static bool CancelCloseBill(StorageInRedModel model)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" UPDATE officedba.StorageInRed SET");
            sql.AppendLine(" Closer          = NULL,");
            sql.AppendLine(" CloseDate      = NULL,");
            sql.AppendLine(" BillStatus              = 2,");
            sql.AppendLine(" ModifiedUserID      = @ModifiedUserID,");
            sql.AppendLine(" ModifiedDate                = getdate()");
            sql.AppendLine(" Where  CompanyCD=@CompanyCD and ID=@ID");

            SqlCommand comm = new SqlCommand();
            comm.CommandText = sql.ToString();
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", model.ModifiedUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", model.ID));

            return SqlHelper.ExecuteTransWithCommand(comm);
        }
        public static bool ConfirmBill(StorageInRedModel model)
        {
            ArrayList lstConfirm = new ArrayList();
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" UPDATE officedba.StorageInRed SET");
            sql.AppendLine(" Confirmor          = @Confirmor,");
            sql.AppendLine(" confirmDate      = getdate(),");
            sql.AppendLine(" BillStatus              = 2,");
            sql.AppendLine(" ModifiedUserID      = @ModifiedUserID,");
            sql.AppendLine(" ModifiedDate                = getdate()");
            sql.AppendLine(" Where  CompanyCD=@CompanyCD and ID=@ID");

            SqlCommand comm = new SqlCommand();
            comm.CommandText = sql.ToString();
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Confirmor", model.Confirmor));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", model.ModifiedUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", model.ID));

            lstConfirm.Add(comm);

            List<StorageInRedDetailModel> modelList = new List<StorageInRedDetailModel>();
            string sqlSele = "select a.CompanyCD,a.ProductID,a.StorageID,a.BatchNo,a.InNo,a.UnitPrice,convert(varchar(10),b.EnterDate,23) HappenDate," +
                " a.ProductCount,a.Remark from officedba.StorageInRedDetail a " +
                " left join officedba.StorageInRed b on b.InNo = a.InNo and a.CompanyCD = b.CompanyCD " +
                " where a.CompanyCD='" + model.CompanyCD + "' and a.InNo=(select InNo from officedba.StorageInRed where ID=" + model.ID + ")";
            DataTable dt = SqlHelper.ExecuteSql(sqlSele);
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    StorageInRedDetailModel modelDetail = new StorageInRedDetailModel();
                    StorageAccountModel StorageAccountM = new StorageAccountModel();

                    if (dt.Rows[i]["ProductID"].ToString() != "")
                    {
                        modelDetail.ProductID = dt.Rows[i]["ProductID"].ToString();
                        StorageAccountM.ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"].ToString());
                    }
                    if (dt.Rows[i]["StorageID"].ToString() != "")
                    {
                        modelDetail.StorageID = dt.Rows[i]["StorageID"].ToString();
                        StorageAccountM.StorageID = Convert.ToInt32(dt.Rows[i]["StorageID"].ToString());
                    }
                    if (dt.Rows[i]["ProductCount"].ToString() != "")
                    {
                        modelDetail.ProductCount = dt.Rows[i]["ProductCount"].ToString();
                        StorageAccountM.ProductCount = Convert.ToDecimal(dt.Rows[i]["ProductCount"].ToString());
                        StorageAccountM.HappenCount = Convert.ToDecimal(dt.Rows[i]["ProductCount"].ToString());
                    }                   

                    StorageAccountM.CompanyCD = dt.Rows[i]["CompanyCD"].ToString();
                    StorageAccountM.BillType = 6;
                    if (dt.Rows[i]["BatchNo"].ToString() != "")
                    {
                        StorageAccountM.BatchNo = dt.Rows[i]["BatchNo"].ToString();
                        modelDetail.BatchNo = dt.Rows[i]["BatchNo"].ToString();
                    }
                    modelList.Add(modelDetail);

                    StorageAccountM.BillNo = dt.Rows[i]["InNo"].ToString();
                    StorageAccountM.Price = Convert.ToDecimal(dt.Rows[i]["UnitPrice"].ToString());
                    StorageAccountM.HappenDate = Convert.ToDateTime(dt.Rows[i]["HappenDate"].ToString());
                    StorageAccountM.Creator = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).EmployeeID;
                    StorageAccountM.PageUrl = "../Office/StorageManager/StorageInRedAdd.aspx";
                    StorageAccountM.ReMark = dt.Rows[i]["Remark"].ToString();

                    SqlCommand commSA = new SqlCommand();
                    commSA = StorageAccountDBHelper.InsertStorageAccountCommand(StorageAccountM, "1");
                    lstConfirm.Add(commSA);
                }
            }
            if (modelList != null && modelList.Count > 0)//明细不为空的时候
            {
                for (int i = 0; i < modelList.Count; i++)
                {
                    SqlCommand commPD = updateStorageProduct(modelList[i].ProductID, modelList[i].StorageID, modelList[i].ProductCount, model.CompanyCD, modelList[i].BatchNo);
                    lstConfirm.Add(commPD);
                }
            }
            foreach (SqlCommand cmd in GetInFromBillInfo(model.CompanyCD, model.ID))
            {
                lstConfirm.Add(cmd);
            }
            return SqlHelper.ExecuteTransWithArrayList(lstConfirm);
        }
 /// <summary>
 /// 保存时基本信息参数设置
 /// </summary>
 /// <param name="comm"></param>
 /// <param name="model"></param>
 private static void SetSaveParameter(SqlCommand comm, StorageInRedModel model)
 {
     if (!string.IsNullOrEmpty(model.ID))
     {
         comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID ", model.ID));//自动生成
     }
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@Creator ", model.Creator));//制单人
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD ", model.CompanyCD));//公司编码
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@InNo ", model.InNo));//入库单编号
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptID ", model.DeptID));//入库部门
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title ", model.Title));//主题
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus ", model.BillStatus));//单据状态
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@Executor ", model.Executor));//入库人
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@EnterDate ", model.EnterDate));//入库时间
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@TotalPrice ", model.TotalPrice));//入库金额合计
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@CountTotal ", model.CountTotal));//入库数量合计
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@Summary ", model.Summary));//摘要
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@Remark ", model.Remark));//备注
     //comm.Parameters.Add(SqlHelper.GetParameterFromString("@ConfirmDate ", model.ConfirmDate));//确认日期
     //comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedDate ", "getdate()"));//最后更新日期
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID ", model.ModifiedUserID));//最后更新用户ID(对应操作用户表中的UserID)
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromType ", model.FromType));//
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromBillID ", model.FromBillID));//
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@ReasonType ", model.ReasonType));//ReasonType
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@CanViewUser ", model.CanViewUser));//可查看人ID
     comm.Parameters.Add(SqlHelper.GetParameterFromString("@CanViewUserName ", model.CanViewUserName));//可查看人Name
 }
        /// <summary>
        /// 更新红冲入库及红冲入库明细
        /// </summary>
        /// <param name="model"></param>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public static bool UpdateStorageInRed(StorageInRedModel model, List<StorageInRedDetailModel> modelList, Hashtable htExtAttr)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.StorageInRed set ");
            strSql.Append("CompanyCD=@CompanyCD,");
            strSql.Append("InNo=@InNo,");
            strSql.Append("Title=@Title,");
            strSql.Append("FromType=@FromType,");
            strSql.Append("FromBillID=@FromBillID,");
            strSql.Append("ReasonType=@ReasonType,");
            strSql.Append("Executor=@Executor,");
            strSql.Append("EnterDate=@EnterDate,");
            strSql.Append("TotalPrice=@TotalPrice,");
            strSql.Append("CountTotal=@CountTotal,");
            strSql.Append("Summary=@Summary,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("CanViewUser=@CanViewUser,");
            strSql.Append("CanViewUserName=@CanViewUserName,");
            strSql.Append("ModifiedDate=getdate(),");
            strSql.Append("ModifiedUserID=@ModifiedUserID");
            strSql.Append(" where ID=@ID ");
            SqlCommand comm = new SqlCommand(strSql.ToString());
            SetSaveParameter(comm, model);
            ArrayList lstUpdate = new ArrayList();
            lstUpdate.Add(comm);//数组加入插入基表的command

            //先删掉明细表中对应单据的所有数据
            string delDetail = "delete from officedba.StorageInRedDetail where CompanyCD='" + model.CompanyCD + "' and InNo='" + model.InNo + "'";
            SqlCommand commdel = new SqlCommand(delDetail);
            lstUpdate.Add(commdel);

            #region 拓展属性
            SqlCommand cmd = new SqlCommand();
            GetExtAttrCmd(model, htExtAttr, cmd);
            if (htExtAttr.Count > 0)
                lstUpdate.Add(cmd);
            #endregion

            if (modelList != null && modelList.Count > 0)//明细不为空的时候
            {
                StringBuilder strSqlDetail = new StringBuilder();
                strSqlDetail.Append("insert into officedba.StorageInRedDetail(");
                strSqlDetail.Append("InNo,ProductID,StorageID,UnitPrice,ProductCount,TotalPrice,Remark,FromType,FromLineNo,ModifiedDate,ModifiedUserID,CompanyCD,SortNo,UsedUnitID,UsedUnitCount,UsedPrice,ExRate,BatchNo)");
                strSqlDetail.Append(" values (");
                strSqlDetail.Append("@InNo,@ProductID,@StorageID,@UnitPrice,@ProductCount,@TotalPrice,@Remark,@FromType,@FromLineNo,getdate(),@ModifiedUserID,@CompanyCD,@SortNo,@UsedUnitID,@UsedUnitCount,@UsedPrice,@ExRate,@BatchNo)");
                strSqlDetail.Append(";select @@IDENTITY");

                for (int i = 0; i < modelList.Count; i++)
                {
                    SqlCommand commDetail = new SqlCommand();
                    commDetail.CommandText = strSqlDetail.ToString();
                    EditInRedDetailInfo(commDetail, modelList[i]);
                    lstUpdate.Add(commDetail);//循环加入数组(重新获取页面上明细数据)

                    //SqlCommand commPD = updateStorageProduct(modelList[i].ProductID, modelList[i].StorageID, modelList[i].ProductCount, model, false);
                    //lstUpdate.Add(commPD);
                }

            }


            return SqlHelper.ExecuteTransWithArrayList(lstUpdate);


        }
예제 #7
0
 public static DataTable GetStorageInRedTableBycondition(string BatchNo,StorageInRedModel model, string timeStart, string timeEnd, string orderby)
 {
     return StorageInRedDBHelper.GetStorageInRedTableBycondition(BatchNo,model, timeStart, timeEnd, orderby);
 }
    protected void LoadPrintInfo()
    {
        PrintParameterSettingModel model = new PrintParameterSettingModel();
        model.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
        model.BillTypeFlag = int.Parse(ConstUtil.BILL_TYPEFLAG_STORAGE);
        model.PrintTypeFlag = ConstUtil.PRINTBILL_TYPEFLAG_INRED;

        StorageInRedModel InRedM_ = new StorageInRedModel();
        InRedM_.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
        InRedM_.ID = this.BillID.ToString();

        #region 初始化 取基本信息及明细信息的字段以及对应的标题
        /*此处需注意在模板设置表里的字段和取基本信息的字段是否一致*/
        string[,] aBase;
        string[,] aDetail;
        if (GetIsDisplayPrice() != "none")
        {
            aBase = new string[,] { 
                                { "{ExtField1}", "ExtField1"},
                                { "{ExtField2}", "ExtField2"},
                                { "{ExtField3}", "ExtField3"},
                                { "{ExtField4}", "ExtField4"},
                                { "{ExtField5}", "ExtField5"},
                                { "{ExtField6}", "ExtField6"},
                                { "{ExtField7}", "ExtField7"},
                                { "{ExtField8}", "ExtField8"},
                                { "{ExtField9}", "ExtField9"},
                                { "{ExtField10}", "ExtField10"},
                                { "入库单编号", "InNo"}, 
                                { "入库单主题", "Title"}, 
                                { "源单类型", "FromType" },
                                { "原始入库单", "FromInNo" },
                                { "原始入库人", "FromExecutor"},
                                { "原始入库时间", "FromEnterDate"},
                                { "原始入库部门", "DeptName"},
                                { "入库人", "ExecutorName"},
                                { "入库时间", "EnterDate"},
                                { "入库原因", "ReasonTypeName"},
                                { "原始摘要", "FromSummary"},
                                { "摘要", "Summary"},
                                { "批次", "BatchNo"},
                                { "数量合计", "CountTotal"},
                                { "金额合计", "A_TotalPrice"},
                                { "制单人", "CreatorName"},
                                { "制单日期", "CreateDate"},
                                { "确认人", "ConfirmorName"},
                                { "确认日期", "ConfirmDate"},
                                { "结单人", "CloserName"},
                                { "结单日期", "CloseDate"},
                                { "最后更新人", "ModifiedUserName"},
                                { "最后更新日期", "ModifiedDate"},
                                { "单据状态", "BillStatus"},
                                { "备注", "Remark"},
                          };
            if (HiddenMoreUnit.Value == "true")
            {
                aDetail = new string[,] { 
                                { "序号", "SortNo"}, 
                                { "物品编号", "ProductNo"}, 
                                { "物品名称", "ProductName" },
                                { "规格", "Specification" },
                                 { "基本单位", "UnitID"},
                                { "单位", "UsedUnitName"},  //++  
                                { "仓库", "StorageName"},
                                { "原始入库量", "FromBillCount"},
                                { "基本数量", "ProductCount"},
                                { "数量", "UsedUnitCount"}, //++
                                { "红冲单价", "UnitPrice"},
                                { "红冲金额", "B_TotalPrice"},
                           };
            }
            else
            {
                aDetail = new string[,] { 
                                { "序号", "SortNo"}, 
                                { "物品编号", "ProductNo"}, 
                                { "物品名称", "ProductName" },
                                { "规格", "Specification" },
                                { "单位", "UnitID"},
                                { "仓库", "StorageName"},
                                { "原始入库量", "FromBillCount"},
                                { "红冲数量", "ProductCount"},
                                { "红冲单价", "UnitPrice"},
                                { "红冲金额", "B_TotalPrice"},
                           };
            }
           
        }
        else
        {
            aBase = new string[,] { 
                                { "{ExtField1}", "ExtField1"},
                                { "{ExtField2}", "ExtField2"},
                                { "{ExtField3}", "ExtField3"},
                                { "{ExtField4}", "ExtField4"},
                                { "{ExtField5}", "ExtField5"},
                                { "{ExtField6}", "ExtField6"},
                                { "{ExtField7}", "ExtField7"},
                                { "{ExtField8}", "ExtField8"},
                                { "{ExtField9}", "ExtField9"},
                                { "{ExtField10}", "ExtField10"},
                                { "入库单编号", "InNo"}, 
                                { "入库单主题", "Title"}, 
                                { "源单类型", "FromType" },
                                { "原始入库单", "FromInNo" },
                                { "原始入库人", "FromExecutor"},
                                { "原始入库时间", "FromEnterDate"},
                                { "原始入库部门", "DeptName"},
                                { "入库人", "ExecutorName"},
                                { "入库时间", "EnterDate"},
                                { "入库原因", "ReasonTypeName"},
                                { "原始摘要", "FromSummary"},
                                { "摘要", "Summary"},
                                 { "批次", "BatchNo"},
                                { "数量合计", "CountTotal"},
                                { "制单人", "CreatorName"},
                                { "制单日期", "CreateDate"},
                                { "确认人", "ConfirmorName"},
                                { "确认日期", "ConfirmDate"},
                                { "结单人", "CloserName"},
                                { "结单日期", "CloseDate"},
                                { "最后更新人", "ModifiedUserName"},
                                { "最后更新日期", "ModifiedDate"},
                                { "单据状态", "BillStatus"},
                                { "备注", "Remark"},
                          };
            if (HiddenMoreUnit.Value == "true")
            {
                aDetail = new string[,] { 
                                { "序号", "SortNo"}, 
                                { "物品编号", "ProductNo"}, 
                                { "物品名称", "ProductName" },
                                { "规格", "Specification" },
                                 { "基本单位", "UnitID"},
                                { "单位", "UsedUnitName"},  //++  
                                { "仓库", "StorageName"},
                                { "原始入库量", "FromBillCount"},
                               { "基本数量", "ProductCount"},
                                { "数量", "UsedUnitCount"}, //++

                           };
            }
            else
            {
                aDetail = new string[,] { 
                                { "序号", "SortNo"}, 
                                { "物品编号", "ProductNo"}, 
                                { "物品名称", "ProductName" },
                                { "规格", "Specification" },
                                { "单位", "UnitID"},
                                { "仓库", "StorageName"},
                                { "原始入库量", "FromBillCount"},
                                { "红冲数量", "ProductCount"},

                           };
            }
            
        }
        #endregion


        #region 1.扩展属性
        int countExt = 0;
        DataTable dtExtTable = XBase.Business.Office.SupplyChain.TableExtFieldsBus.GetAllList(((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD, "", "officedba.StorageInRed");
        if (dtExtTable.Rows.Count > 0)
        {
            for (int i = 0; i < dtExtTable.Rows.Count; i++)
            {
                for (int x = 0; x < (aBase.Length / 2) - 15; x++)
                {
                    if (x == i)
                    {
                        aBase[x, 0] = dtExtTable.Rows[i]["EFDesc"].ToString();
                        countExt++;
                    }
                }
            }
        }
        #endregion

        #region 2.所设的打印模板设置

        DataTable dbPrint = XBase.Business.Common.PrintParameterSettingBus.GetPrintParameterSettingInfo(model);
        DataTable dtDetail = StorageInRedBus.GetStorageInRedDetailInfo(InRedM_.ID, InRedM_.CompanyCD);
        DataTable dtMain = StorageInRedBus.GetStorageInRedInfo(InRedM_.ID, InRedM_.CompanyCD);
        string strBaseFields = "";
        string strDetailFields = "";

        if (dbPrint.Rows.Count > 0)
        {
            #region 设置过打印模板设置时 直接取出表里设置的值
            isSeted.Value = "1";
            strBaseFields = dbPrint.Rows[0]["BaseFields"].ToString();
            strDetailFields = dbPrint.Rows[0]["DetailFields"].ToString();
            #endregion
        }
        else
        {

            #region 未设置过打印模板设置 默认显示所有的
            isSeted.Value = "0";

            /*未设置过打印模板设置时,默认显示的字段  基本信息字段*/
            for (int m = 10; m < aBase.Length / 2; m++)
            {
                strBaseFields = strBaseFields + aBase[m, 1] + "|";
            }
            /*未设置过打印模板设置时,默认显示的字段 基本信息字段+扩展信息字段*/
            if (countExt > 0)
            {
                for (int i = 0; i < countExt; i++)
                {
                    strBaseFields = strBaseFields + "ExtField" + (i + 1) + "|";
                }
            }
            /*未设置过打印模板设置时,默认显示的字段 明细信息字段*/
            for (int n = 0; n < aDetail.Length / 2; n++)
            {
                strDetailFields = strDetailFields + aDetail[n, 1] + "|";
            }
            #endregion

            /*两种都可以*/
        }
        #endregion

        #region 3.输出主表信息
        if (!string.IsNullOrEmpty(strBaseFields))
        {
            tableBase.InnerHtml = WritePrintPageTable("红冲入库单", strBaseFields.TrimEnd('|'), strDetailFields.TrimEnd('|'), aBase, aDetail, dtMain, dtDetail, true);
        }
        #endregion

        #region 4.输出明细信息
        if (!string.IsNullOrEmpty(strDetailFields))
        {
            tableDetail.InnerHtml = WritePrintPageTable("红冲入库单", strBaseFields.TrimEnd('|'), strDetailFields.TrimEnd('|'), aBase, aDetail, dtMain, dtDetail, false);
        }
        #endregion

    }
        /// <summary>
        /// 获取红冲入库详细信息(加载页面的时候)
        /// </summary>
        /// <returns>DataTable</returns>
        public static DataTable GetStorageInRedDetailInfo(StorageInRedModel model)
        {
            //a->officedba.StorageInRed
            //b->officedba.StorageInRedDetail
            //l->officedba.SellBackDetail

            StringBuilder sql = new StringBuilder();
            sql.AppendLine("SELECT DISTINCT ");
            sql.AppendLine("a.ID ,a.CanViewUser,a.CanViewUserName,a.ExtField1,a.ExtField2,a.ExtField3,a.ExtField4,a.ExtField5,a.ExtField6,a.ExtField6,a.ExtField7,a.ExtField8,a.ExtField9,a.ExtField10 ");
            sql.AppendLine(",a.CompanyCD                                                                                                              ");
            sql.AppendLine(",a.InNo                                                                                                                   ");
            sql.AppendLine(",a.FromType                                                                                                               ");
            sql.AppendLine(",a.FromBillID                                                                                                             ");
            sql.AppendLine(",a.ReasonType   ");
            sql.AppendLine(",case a.FromType                                                                                                           ");
            sql.AppendLine("when '1' then (select  bb.InNo from officedba.StorageInPurchase bb where bb.id=a.FrombillID)                             ");
            sql.AppendLine("when '2' then (select  cc.InNo from officedba.StorageInProcess cc where cc.id=a.FrombillID)                               ");
            sql.AppendLine("when '3' then (select  dd.InNo from officedba.StorageInOther dd where dd.id=a.FrombillID)                                 ");
            sql.AppendLine("end FromInNo                                                                                                             ");

            sql.AppendLine(",case a.FromType                                                                                                           ");
            sql.AppendLine("when '1' then (select  CONVERT(VARCHAR(10),bb.EnterDate, 21) from officedba.StorageInPurchase bb where bb.id=a.FrombillID)                             ");
            sql.AppendLine("when '2' then (select  CONVERT(VARCHAR(10),cc.EnterDate, 21) from officedba.StorageInProcess cc where cc.id=a.FrombillID)                               ");
            sql.AppendLine("when '3' then (select  CONVERT(VARCHAR(10),dd.EnterDate, 21) from officedba.StorageInOther dd where dd.id=a.FrombillID)                                 ");
            sql.AppendLine("end FromEnterDate                                                                                                             ");

            sql.AppendLine(",case a.FromType                                                                                                           ");
            sql.AppendLine("when '1' then (select  ee.EmployeeName from officedba.StorageInPurchase bb left join officedba.EmployeeInfo ee on bb.Executor=ee.ID where bb.id=a.FrombillID)                             ");
            sql.AppendLine("when '2' then (select  ee.EmployeeName from officedba.StorageInProcess cc left join officedba.EmployeeInfo ee on cc.Executor=ee.ID where cc.id=a.FrombillID)                               ");
            sql.AppendLine("when '3' then (select  ee.EmployeeName from officedba.StorageInOther dd left join officedba.EmployeeInfo ee on dd.Executor=ee.ID where dd.id=a.FrombillID)                                 ");
            sql.AppendLine("end FromExecutor                                                                                                             ");

            sql.AppendLine(",case a.FromType                                                                                                           ");
            sql.AppendLine("when '1' then (select  bb.ProductCount from officedba.StorageInPurchaseDetail bb left join officedba.StorageInPurchase ee on bb.InNo=ee.InNo and bb.SortNo=b.FromLineNo where ee.id=a.FrombillID)");
            sql.AppendLine("when '2' then (select  bb.ProductCount from officedba.StorageInProcessDetail  bb left join officedba.StorageInProcess  ee on bb.InNo=ee.InNo and bb.SortNo=b.FromLineNo where ee.ID=a.FrombillID)");
            sql.AppendLine("when '3' then (select  bb.ProductCount from officedba.StorageInOtherDetail bb left join officedba.StorageInOther ee on ee.InNo=bb.InNo and bb.SortNo=b.FromLineNo where ee.id=a.FrombillID)      ");
            sql.AppendLine("end FromBillCount                                                                                                             ");

            sql.AppendLine(",case a.FromType                                                                                                           ");
            sql.AppendLine("when '1' then (select  ISNULL(bb.Summary,'') from officedba.StorageInPurchase bb where bb.id=a.FrombillID)                             ");
            sql.AppendLine("when '2' then (select  ISNULL(cc.Summary,'') from officedba.StorageInProcess cc where cc.id=a.FrombillID)                               ");
            sql.AppendLine("when '3' then (select  ISNULL(dd.Summary,'') from officedba.StorageInOther dd where dd.id=a.FrombillID)                                 ");
            sql.AppendLine("end FromSummary                                                                                                             ");

            sql.AppendLine(",a.Title                                                                                                                  ");
            sql.AppendLine(",a.DeptID                                                                                                                 ");
            sql.AppendLine(",j.DeptName                                                                                                               ");
            sql.AppendLine(",a.Executor                                                                                                               ");
            sql.AppendLine(",ISNULL(f.EmployeeName,'') as ExecutorName                                                                                ");
            sql.AppendLine(",case when a.EnterDate Is NULL then '' else CONVERT(VARCHAR(10),a.EnterDate, 21) end AS EnterDate                         ");
            sql.AppendLine(",a.BillStatus                                                                                                             ");
            sql.AppendLine(",ISNULL(a.Summary,'') as Summary                                                                                          ");
            sql.AppendLine(",ISNULL(a.TotalPrice,'0') as A_TotalPrice                                                                                 ");
            sql.AppendLine(",ISNULL(a.CountTotal,'0') as CountTotal                                                                                   ");
            sql.AppendLine(",a.Creator                                                                                                                ");
            sql.AppendLine(",ISNULL(g.EmployeeName,'') as CreatorName                                                                                 ");
            sql.AppendLine(",case when a.CreateDate Is NULL then '' else CONVERT(VARCHAR(10),a.CreateDate, 21) end AS CreateDate                      ");
            sql.AppendLine(",a.Confirmor                                                                                                              ");
            sql.AppendLine(",ISNULL(h.EmployeeName,'') as ConfirmorName                                                                               ");
            sql.AppendLine(",case when a.ConfirmDate Is NULL then '' else CONVERT(VARCHAR(10),a.ConfirmDate, 21) end AS ConfirmDate                   ");
            sql.AppendLine(",a.Closer                                                                                                                 ");
            sql.AppendLine(",ISNULL(i.EmployeeName,'') as CloserName                                                                                  ");
            sql.AppendLine(",case when a.CloseDate Is NULL then '' else CONVERT(VARCHAR(10),a.CloseDate, 21) end AS CloseDate                         ");
            sql.AppendLine(",case when a.ModifiedDate Is NULL then '' else CONVERT(VARCHAR(10),a.ModifiedDate, 21) end AS ModifiedDate                ");
            sql.AppendLine(",a.ModifiedUserID                                                                                                         ");
            sql.AppendLine(",a.ModifiedUserID as ModifiedUserName                                                                                       ");
            sql.AppendLine(",ISNULL(a.Remark,'') as Remark                                                                                            ");
            sql.AppendLine(",b.ID as DetailID                                                                                                         ");
            sql.AppendLine(",b.ProductID                                                                                                              ");
            sql.AppendLine(",c.ProdNo as ProductNo                                                                                                    ");
            sql.AppendLine(",c.ProductName                                                                                                            ");
            sql.AppendLine(",ISNULL(c.MinusIs,0) as MinusIs");
            sql.AppendLine(",c.Specification,c.IsBatchNo  ");
            sql.AppendLine(",q.CodeName as UnitID                                                                                                          ");
            sql.AppendLine(",isnull(b.UnitPrice,0) as UnitPrice                                                                                                 ");
            sql.AppendLine(",b.StorageID                                                                                                              ");
            sql.AppendLine(",b.TotalPrice as B_TotalPrice                                                                                             ");
            sql.AppendLine(",b.FromType                                                                                                               ");
            sql.AppendLine(",b.FromBillID                                                                                                             ");
            sql.AppendLine(",b.FromLineNo                                                                                                             ");
            sql.AppendLine(",b.SortNo                                                                                                                 ");
            sql.AppendLine(",b.UsedUnitID ");
            sql.AppendLine(",b.UsedUnitCount ");
            sql.AppendLine(",isnull(b.UsedPrice,0)UsedPrice ");
            sql.AppendLine(",b.ExRate ");
            sql.AppendLine(",b.BatchNo ");
            sql.AppendLine(",b.Remark as DetaiRemark                                                                                                  ");
            sql.AppendLine(",b.ProductCount                                                                                             ");
            sql.AppendLine(" ,ISNULL(s.ProductCount,0)+ISNULL(s.RoadCount,0)+ISNULL(s.InCount,0)-ISNULL(s.OrderCount,0)-ISNULL(s.OutCount,0) as UseCount ");
            sql.AppendLine("FROM officedba.StorageInRed a                                                                                       ");
            sql.AppendLine("left join officedba.StorageInRedDetail b                                                                                  ");
            sql.AppendLine("on a.InNo=b.InNo  and a.CompanyCD=b.CompanyCD                                                                                                         ");
            sql.AppendLine("left join officedba.ProductInfo c on c.ID=b.ProductID                                                                     ");
            sql.AppendLine("left join officedba.EmployeeInfo f on a.Executor=f.ID                                                                     ");
            sql.AppendLine("left join officedba.EmployeeInfo g on a.Creator=g.ID                                                                      ");
            sql.AppendLine("left join officedba.EmployeeInfo h on a.Confirmor=h.ID                                                                    ");
            sql.AppendLine("left join officedba.EmployeeInfo i on a.Closer=i.ID                                                                       ");
            sql.AppendLine("left join officedba.DeptInfo j on a.DeptID=j.ID                                                                           ");
            sql.AppendLine("left join officedba.CodeUnitType q on q.ID=c.UnitID               ");
            sql.AppendLine("left join officedba.StorageProduct s on s.CompanyCD=a.CompanyCD and s.StorageID=b.StorageID and b.ProductID=s.ProductID  and s.BatchNo = b.BatchNo ");
            sql.AppendLine("left join (select w.UserID,x.EmployeeName from officedba.UserInfo w ,officedba.EmployeeInfo x where w.EmployeeID =x.ID) m ");
            sql.AppendLine("on a.ModifiedUserID=m.UserID 																							  ");
            sql.AppendLine("   where b.CompanyCD='" + model.CompanyCD + "' and a.id=" + model.ID);
            return SqlHelper.ExecuteSql(sql.ToString());
        }
        /// <summary>
        /// 扩展属性保存操作
        /// </summary>
        /// <returns></returns>
        private static void GetExtAttrCmd(StorageInRedModel model, Hashtable htExtAttr, SqlCommand cmd)
        {
            try
            {
                string strSql = string.Empty;

                strSql = "UPDATE officedba.StorageInRed set ";
                foreach (DictionaryEntry de in htExtAttr)// fileht为一个Hashtable实例
                {
                    strSql += de.Key.ToString().Trim() + "=@" + de.Key.ToString().Trim() + ",";
                    cmd.Parameters.AddWithValue("@" + de.Key.ToString().Trim(), de.Value.ToString().Trim());
                }
                int iLength = strSql.Length - 1;
                strSql = strSql.Substring(0, iLength);
                strSql += " where CompanyCD = @CompanyCD  AND InNo = @InNo";
                cmd.Parameters.AddWithValue("@CompanyCD", model.CompanyCD);
                cmd.Parameters.AddWithValue("@InNo", model.InNo);
                cmd.CommandText = strSql;
            }
            catch (Exception)
            { }


        }
예제 #11
0
 public static string ISBigUseCountWhenCant(StorageInRedModel model)
 {
     return StorageInRedDBHelper.ISBigUseCountWhenCant(model);
 }
예제 #12
0
 /// <summary>
 /// 获取红冲入库详细信息(加载页面的时候)
 /// </summary>
 /// <returns>DataTable</returns>
 public static DataTable GetStorageInRedDetailInfo(StorageInRedModel model)
 {
     return StorageInRedDBHelper.GetStorageInRedDetailInfo(model);
 }
예제 #13
0
 /// <summary>
 /// 获取入库单列表
 /// </summary>
 /// <param name="companycd"></param>
 /// <returns></returns>
 public static DataTable GetStorageInList(StorageInRedModel model, string InType)
 {
     return StorageInRedDBHelper.GetStorageInList(model, InType);
 }
예제 #14
0
        public static bool CancelCloseBill(StorageInRedModel model)
        {
            //获取登陆用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //设置公司代码
            model.CompanyCD = userInfo.CompanyCD;
            //定义返回变量
            bool isSucc = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            //获取公司代码
            string companyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;

            //执行删除操作
            try
            {
                //执行更新
                isSucc = StorageInRedDBHelper.CancelCloseBill(model);
            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }

            //定义变量
            string remark;
            //成功时
            if (isSucc)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }
            //操作日志
            LogInfoModel logModel = InitLogInfo(model.ID);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = "取消结单";
            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);
            return isSucc;
        }
        /// <summary>
        /// 查找出当前单据中明细,所有不允许的负库存的物品,然后判断是否出库数量大于负库存
        /// </summary>
        /// <param name="model">CompanyCD,ID</param>
        /// <returns>string:行号数组|对应行号的可用库存</returns>
        public static string ISBigUseCountWhenCant(StorageInRedModel model)
        {
            string batchsql = "SELECT A.BatchNo FROM officedba.StorageInRedDetail A LEFT OUTER JOIN officedba.StorageInRed B on A.InNo=B.InNo AND A.CompanyCD=B.CompanyCD where A.CompanyCD='" + model.CompanyCD + "' and B.ID=" + model.ID + "";
            DataTable dtbatch = SqlHelper.ExecuteSql(batchsql.ToString());
                        
            string RowNumList = string.Empty;//有状况的明细行号
            string UseCountList = string.Empty;//有状况的明细对应的可有库存

            if (dtbatch.Rows.Count > 0)
            {
                for (int i = 0; i < dtbatch.Rows.Count; i++)
                {
                    StringBuilder sql = new StringBuilder();
                    sql.AppendLine("select b.ID,a.ProductID,a.StorageID,a.ProductCount                                                                          ");
                    sql.AppendLine(",ISNULL(d.MinusIs,0) as MinusIs                                                                                             ");
                    sql.AppendLine(",ISNULL(c.ProductCount,0) as UseCount ");
                    sql.AppendLine(" from officedba.StorageInRedDetail a                                                                                      ");
                    sql.AppendLine("left join officedba.StorageInRed b on a.InNo=b.InNo                                                                     ");
                    sql.AppendLine("left join officedba.StorageProduct c on a.StorageID=c.StorageID and a.ProductID=c.ProductID                               "); //AND a.BatchNo=c.BatchNo 
                    if (dtbatch.Rows[i]["BatchNo"].ToString().Trim() != "")
                        sql.AppendLine(" AND a.BatchNo=c.BatchNo    ");
                    sql.AppendLine("left join officedba.ProductInfo d on d.ID=a.ProductID                                                                       ");
                    sql.AppendLine(" where  a.CompanyCD='" + model.CompanyCD + "' and b.ID=" + model.ID + " and ISNULL(d.MinusIS,0)='0' ");
                    if (dtbatch.Rows[i]["BatchNo"].ToString().Trim() != "")
                        sql.AppendLine(" AND c.BatchNo='" + dtbatch.Rows[i]["BatchNo"].ToString().Trim() + "'    ");
                    else
                        sql.AppendLine(" AND (c.BatchNo is null or c.BatchNo='')   ");
                    
                    DataTable dt = SqlHelper.ExecuteSql(sql.ToString());
                    if (dt.Rows.Count > 0)
                    {
                        if (decimal.Parse(dt.Rows[0]["ProductCount"].ToString()) > decimal.Parse(dt.Rows[0]["UseCount"].ToString()))
                        {
                            if (RowNumList == "" || RowNumList == string.Empty)
                            {
                                RowNumList = (i + 1).ToString();
                                UseCountList = dt.Rows[i]["UseCount"].ToString();
                            }
                            else
                            {
                                RowNumList += "," + (i + 1).ToString();
                                UseCountList += "," + dt.Rows[i]["UseCount"].ToString();
                            }
                        }
                    }                
                }
            }

            if (RowNumList == "" || RowNumList == string.Empty)
            {
                return "";
            }
            else
            {
                return RowNumList + "|" + UseCountList;
            }
            #region 作废SQL
            //StringBuilder sql = new StringBuilder();
            //sql.AppendLine("select b.FromType,b.ID,a.ProductID,a.StorageID ");
            //if (((UserInfoUtil)SessionUtil.Session["UserInfo"]).IsMoreUnit == true)
            //{
            //    sql.AppendLine(",a.UsedUnitCount ProductCount ");
            //}
            //else
            //{
            //    sql.AppendLine(",a.ProductCount ");
            //}
            //sql.AppendLine(",ISNULL(d.MinusIs,0) as MinusIs                                                                                             ");
            //sql.AppendLine(",ISNULL(c.ProductCount,0)+ISNULL(c.RoadCount,0)+ISNULL(c.InCount,0)-ISNULL(c.OrderCount,0)-ISNULL(c.OutCount,0) as UseCount ");
            //sql.AppendLine(" from officedba.StorageInRedDetail a                                                                                        ");
            //sql.AppendLine("left join officedba.StorageInRed b on a.InNo=b.InNo                                                                         ");
            //sql.AppendLine("left join officedba.StorageProduct c on a.StorageID=c.StorageID and a.ProductID=c.ProductID ");
            //sql.AppendLine("left join officedba.ProductInfo d on d.ID=a.ProductID                                                                       ");
            //sql.AppendLine(" where  a.CompanyCD='" + model.CompanyCD + "' and b.ID=" + model.ID + " and ISNULL(d.MinusIS,0)='0'");
            #endregion
        }
        /// <summary>
        /// 查询红冲入库单
        /// </summary>
        /// <returns>DataTable</returns>
        public static DataTable GetStorageInRedTableBycondition(string BatchNo,StorageInRedModel model, string timeStart, string timeEnd, int pageIndex, int pageCount, string ord, ref int TotalCount)
        {
            //列表:入库单编号、入库单主题、源单类型、原始入库单、入库部门、人库人、入库时间、红冲数量、红冲金额、摘要、单据状态。
            string CanUser = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).EmployeeID.ToString();
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("select DISTINCT x.*,ISNULL(l.DeptName,'') as DeptName,ISNULL(m.EmployeeName,'') as ExecutorName from                                                                                                    ");
            sql.AppendLine("(select a.ID                                                                                                                                                                    ");
            sql.AppendLine(",ISNULL(c.CodeName,'') as CodeName");
            sql.AppendLine(",ISNULL(a.InNo,'') AS InNo                                                                                                                                                      ");
            sql.AppendLine(",ISNULL(a.Title,'') AS Title                                                                                                                                                    ");
            sql.AppendLine(",ISNULL(a.CountTotal,'0') AS CountTotal                                                                                                                                         ");
            sql.AppendLine(",ISNULL(a.TotalPrice,'0') AS TotalPrice                                                                                                                                         ");
            sql.AppendLine(",ISNULL(a.Summary,'') AS Summary                                                                                                                                                ");
            sql.AppendLine(",case a.billStatus when  '1' then '制单' when '2' then '执行' when '3' then '变更' when '4' then '手工结单' when '5' then '自动结单' else '' end as BillStatusName              ");
            sql.AppendLine(",case a.FromType when '1' then '采购入库单' when '2' then '生产完工入库单' when '3' then '其他入库单' end FromType                                                              ");
            sql.AppendLine(",case a.fromtype                                                                                                                                                                ");
            sql.AppendLine("when '1' then (select distinct b.InNO from  officedba.StorageInPurchase b where b.id=a.frombillID)                                                                              ");
            sql.AppendLine("when '2' then (select distinct c.InNO from officedba.StorageInProcess c where c.id=a.frombillID)                                                                                ");
            sql.AppendLine("when '3' then (select distinct d.InNO from officedba.StorageInOther d where d.id=a.frombillID)                                                                                  ");
            sql.AppendLine("end FromInNo,                                                                                                                                                                   ");
            sql.AppendLine("case a.fromtype                                                                                                                                                                 ");
            sql.AppendLine("when '1' then (select distinct ISNULL(b.DeptID,'') from  officedba.StorageInPurchase b where b.id=a.frombillID)                                                                            ");
            sql.AppendLine("when '2' then (select distinct ISNULL(c.DeptID,'') from officedba.StorageInProcess c where c.id=a.frombillID)                                                                              ");
            sql.AppendLine("when '3' then (select distinct ISNULL(d.DeptID,'') from officedba.StorageInOther d where d.id=a.frombillID)                                                                                ");
            sql.AppendLine("end DeptID,                                                                                                                                                                     ");
            sql.AppendLine("a.Executor,                                                                                                                                                                   ");
            sql.AppendLine("case when a.EnterDate Is NULL then '' else CONVERT(VARCHAR(10),a.EnterDate, 21) end as EnterDate");
            //sql.AppendLine("case a.fromtype                                                                                                                                                                 ");
            //sql.AppendLine("when '1' then (select distinct case when b.EnterDate Is NULL then '' else CONVERT(VARCHAR(10),b.EnterDate, 21) end from officedba.StorageInPurchase b where b.id=a.frombillID)  ");
            //sql.AppendLine("when '2' then (select distinct case when c.EnterDate Is NULL then '' else CONVERT(VARCHAR(10),c.EnterDate, 21) end from officedba.StorageInProcess c where c.id=a.frombillID)   ");
            //sql.AppendLine("when '3' then (select distinct case when d.EnterDate Is NULL then '' else CONVERT(VARCHAR(10),d.EnterDate, 21) end from officedba.StorageInOther d where d.id=a.frombillID)     ");
            //sql.AppendLine("end EnterDate                                                                                                                                                                   ");
            sql.AppendLine(" from officedba.StorageInRed a ");
            sql.AppendLine(" left join officedba.CodeReasonType as c on a.ReasonType=c.ID");
            sql.AppendLine(" left join officedba.StorageInRedDetail as d on d.InNo=a.InNo ");
            sql.AppendLine(" where a.CompanyCD=@CompanyCD  AND (CHARINDEX('," + CanUser + ",',','+a.CanViewUser+',')>0 OR a.CanViewUser='' or a.CanViewUser is null OR  a.Creator=" + CanUser + ")");
            //查询条件:入库单编号、入库单主题、源单类型(选择)、原始入库单(选择)、入库部门、入库人(选择)、入库时间(日期段,日期控件)、单据状态(下拉列表)
            SqlCommand comm = new SqlCommand();
            //添加公司代码参数
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));

            if (!string.IsNullOrEmpty(BatchNo))
            {
                sql.AppendLine("	and d.BatchNo like '%'+ @BatchNo +'%' ");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BatchNo", BatchNo));
            }
            if (!string.IsNullOrEmpty(model.InNo))
            {
                sql.AppendLine("	and a.InNo like '%'+ @InNo +'%' ");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@InNo", model.InNo));
            }
            if (!string.IsNullOrEmpty(model.Title))
            {
                sql.AppendLine(" and a.Title like '%'+ @Title +'%'");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title", model.Title));
            }
            if (!string.IsNullOrEmpty(model.FromBillID))
            {
                sql.AppendLine(" and a.FromBillID = @FromBillID");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromBillID", model.FromBillID));
            }
            if (!string.IsNullOrEmpty(model.FromType))
            {
                sql.AppendLine(" and a.FromType = @FromType");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromType", model.FromType));
            }
            if (!string.IsNullOrEmpty(model.DeptID))
            {
                sql.AppendLine(" and a.DeptID = @DeptID");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptID", model.DeptID));
            }
            if (!string.IsNullOrEmpty(model.Executor))
            {
                sql.AppendLine(" and a.Executor = @Executor");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Executor", model.Executor));
            }
            if (!string.IsNullOrEmpty(model.ReasonType))
            {
                sql.AppendLine(" and a.ReasonType = @ReasonType");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@ReasonType", model.ReasonType));
            }
            if (!string.IsNullOrEmpty(timeStart))
            {
                sql.AppendLine(" and a.EnterDate>=@timeStart");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@timeStart", timeStart));
            }

            if (!string.IsNullOrEmpty(timeEnd))
            {
                sql.AppendLine(" and a.EnterDate<=@timeEnd");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@timeEnd", timeEnd));
            }
            if (!string.IsNullOrEmpty(model.BillStatus))
            {
                sql.AppendLine(" and a.BillStatus=@BillStatus");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", model.BillStatus));
            }
            if (!string.IsNullOrEmpty(model.EFIndex) && !string.IsNullOrEmpty(model.EFDesc))
            {
                sql.AppendLine(" and a.ExtField" + model.EFIndex + " LIKE @EFDesc");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@EFDesc", "%" + model.EFDesc + "%"));
            }
            sql.AppendLine(") x                                                                                        ");
            sql.AppendLine("left join officedba.DeptInfo l on l.ID=x.DeptID                                            ");
            sql.AppendLine("left join officedba.EmployeeInfo m on m.ID=x.Executor");

            comm.CommandText = sql.ToString();
            return SqlHelper.PagerWithCommand(comm, pageIndex, pageCount, ord, ref TotalCount);
        }
        /// <summary>
        /// 查找出当前单据中明细,所有允许的负库存的物品,然后判断是否出库数量大于负库存
        /// </summary>
        /// <param name="model">CompanyCD,ID</param>
        /// <returns>string:行号数组|对应行号的可用库存</returns>
        public static string ISBigUseCountWhenCan(StorageInRedModel model)
        {
            string RowNumList = string.Empty;//有状况的明细行号
            string UseCountList = string.Empty;//有状况的明细对应的可有库存
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("select b.FromType,b.ID,a.ProductID,a.StorageID,a.ProductCount                                                               ");
            sql.AppendLine(",ISNULL(d.MinusIs,0) as MinusIs                                                                                             ");
            sql.AppendLine(",ISNULL(c.ProductCount,0)+ISNULL(c.RoadCount,0)+ISNULL(c.InCount,0)-ISNULL(c.OrderCount,0)-ISNULL(c.OutCount,0) as UseCount ");
            sql.AppendLine(" from officedba.StorageInRedDetail a                                                                                        ");
            sql.AppendLine("left join officedba.StorageInRed b on a.InNo=b.InNo                                                                         ");
            sql.AppendLine("left join officedba.StorageProduct c on a.StorageID=c.StorageID and a.ProductID=c.ProductID                                 ");
            sql.AppendLine("left join officedba.ProductInfo d on d.ID=a.ProductID                                                                       ");
            sql.AppendLine(" where  a.CompanyCD='" + model.CompanyCD + "' and b.ID=" + model.ID + " and ISNULL(d.MinusIS,0)='1'");
            DataTable dt = SqlHelper.ExecuteSql(sql.ToString());
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (decimal.Parse(dt.Rows[i]["ProductCount"].ToString()) > decimal.Parse(dt.Rows[i]["UseCount"].ToString()))
                    {
                        if (RowNumList == "" || RowNumList == string.Empty)
                        {
                            RowNumList = (i + 1).ToString();
                            UseCountList = dt.Rows[i]["UseCount"].ToString();
                        }
                        else
                        {
                            RowNumList += "," + (i + 1).ToString();
                            UseCountList += "," + dt.Rows[i]["UseCount"].ToString();
                        }
                    }
                }
            }
            if (RowNumList == "" || RowNumList == string.Empty)
            {
                return "";
            }
            else
            {
                return RowNumList + "|" + UseCountList;
            }

        }
        /// <summary>
        /// 插入红冲入库和红冲入库明细
        /// </summary>
        /// <param name="model"></param>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public static bool InsertStorageInRed(StorageInRedModel model, List<StorageInRedDetailModel> modelList, out int IndexIDentity, Hashtable htExtAttr)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into officedba.StorageInRed(");
            strSql.Append("CompanyCD,InNo,Title,FromType,FromBillID,ReasonType,DeptID,Executor,EnterDate,TotalPrice,CountTotal,Summary,Remark,Creator,CreateDate,BillStatus,ModifiedDate,ModifiedUserID,CanViewUser,CanViewUserName)");
            strSql.Append(" values (");
            strSql.Append("@CompanyCD,@InNo,@Title,@FromType,@FromBillID,@ReasonType,@DeptID,@Executor,@EnterDate,@TotalPrice,@CountTotal,@Summary,@Remark,@Creator,getdate(),@BillStatus,getdate(),@ModifiedUserID,@CanViewUser,@CanViewUserName)");
            strSql.AppendLine("set @IndexID = @@IDENTITY");
            SqlCommand comm = new SqlCommand();
            comm.CommandText = strSql.ToString();
            SqlParameter IndexID = new SqlParameter("@IndexID", SqlDbType.Int);
            IndexID.Direction = ParameterDirection.Output;
            comm.Parameters.Add(IndexID);
            SetSaveParameter(comm, model);
            ArrayList lstInsert = new ArrayList();
            lstInsert.Add(comm);//数组加入插入基表的command

            #region 拓展属性
            SqlCommand cmd = new SqlCommand();
            GetExtAttrCmd(model, htExtAttr, cmd);
            if (htExtAttr.Count > 0)
                lstInsert.Add(cmd);
            #endregion

            if (modelList != null && modelList.Count > 0)//明细为空的时候
            {
                //插入红冲入库明细
                StringBuilder strSqlDetail = new StringBuilder();
                strSqlDetail.Append("insert into officedba.StorageInRedDetail(");
                strSqlDetail.Append("InNo,ProductID,StorageID,UnitPrice,ProductCount,TotalPrice,Remark,FromType,FromBillID,FromLineNo,ModifiedDate,ModifiedUserID,CompanyCD,SortNo,UsedUnitID,UsedUnitCount,UsedPrice,ExRate,BatchNo)");
                strSqlDetail.Append(" values (");
                strSqlDetail.Append("@InNo,@ProductID,@StorageID,@UnitPrice,@ProductCount,@TotalPrice,@Remark,@FromType,@FromBillID,@FromLineNo,getdate(),@ModifiedUserID,@CompanyCD,@SortNo,@UsedUnitID,@UsedUnitCount,@UsedPrice,@ExRate,@BatchNo)");
                strSqlDetail.Append(";select @@IDENTITY");

                for (int i = 0; i < modelList.Count; i++)
                {

                    ////更新减少分仓存量表中的现有存量和可用数量
                    //#region 更新减少分仓存量表中的现有存量和可用数量
                    //SqlCommand commPD = updateStorageProduct(int.Parse(modelList[i].ProductID), int.Parse(modelList[i].StorageID), decimal.Parse(modelList[i].ProductCount), model, false);
                    //lstInsert.Add(commPD);
                    //#endregion

                    SqlCommand commDetail = new SqlCommand();
                    commDetail.CommandText = strSqlDetail.ToString();
                    EditInRedDetailInfo(commDetail, modelList[i]);
                    lstInsert.Add(commDetail);//循环加入数组(重新获取页面上明细数据)
                }
            }

            bool result = SqlHelper.ExecuteTransWithArrayList(lstInsert);
            if (result)
            {
                IndexIDentity = int.Parse(((SqlCommand)lstInsert[0]).Parameters["@IndexID"].Value.ToString());
            }
            else
            {
                IndexIDentity = 0;
            }
            return result;


        }
    protected void btnImport_Click(object sender, ImageClickEventArgs e)
    {
        StorageInRedModel model = new StorageInRedModel();
        model.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
        string EnterDateStart = string.Empty;
        string EnterDateEnd = string.Empty;
        model.InNo = txtInNo.Value;
        model.Title = txtTitle.Value;
        model.ReasonType = ddlReasonType.SelectedValue;
        if (hidFromBillID.Value == "undefined")
        {
            hidFromBillID.Value = "";
        }
        model.FromBillID = hidFromBillID.Value;
        model.DeptID = txtDeptID.Value;
        model.BillStatus = sltBillStatus.Value;
        model.Executor = txtExecutorID.Value;
        model.FromType = sltFromType.Value;
        EnterDateStart = txtEnterDateStart.Value;
        EnterDateEnd = txtEnterDateEnd.Value;
        string BatchNo = txtBatchNo.Value;
        string orderBy = txtorderBy.Value;
        if (!string.IsNullOrEmpty(orderBy))
        {
            if (orderBy.Split('_')[1] == "a")
            {
                orderBy = orderBy.Split('_')[0] + " asc";
            }
            else
            {
                orderBy = orderBy.Split('_')[0] + " desc";
            }
        }
        DataTable dt = StorageInRedBus.GetStorageInRedTableBycondition(BatchNo,model, EnterDateStart, EnterDateEnd, orderBy);
        if (((UserInfoUtil)SessionUtil.Session["UserInfo"]).IsDisplayPrice)
        {
            OutputToExecl.ExportToTableFormat(this, dt,
    new string[] { "单据编号", "单据主题", "源单类型", "源单编号", "入库部门", "入库人", "入库时间", "入库原因", "红冲数量", "红冲金额", "摘要", "单据状态" },
    new string[] { "InNo", "Title", "FromType", "FromInNo", "DeptName", "ExecutorName", "EnterDate", "CodeName", "CountTotal", "TotalPrice", "Summary", "BillStatusName" },
    "红冲入库列表");
        }
        else
        {
            OutputToExecl.ExportToTableFormat(this, dt,
               new string[] { "单据编号", "单据主题", "源单类型", "源单编号", "入库部门", "入库人", "入库时间", "入库原因", "红冲数量",  "摘要", "单据状态" },
               new string[] { "InNo", "Title", "FromType", "FromInNo", "DeptName", "ExecutorName", "EnterDate", "CodeName", "CountTotal", "Summary", "BillStatusName" },
               "红冲入库列表");
        }

    }
예제 #20
0
 /// <summary>
 /// 查询其他入库单
 /// </summary>
 /// <returns>DataTable</returns>
 public static DataTable GetStorageInRedTableBycondition(string BatchNo,StorageInRedModel model, string timeStart, string timeEnd, int pageIndex, int pageCount, string ord, ref int TotalCount)
 {
     return StorageInRedDBHelper.GetStorageInRedTableBycondition(BatchNo,model, timeStart, timeEnd, pageIndex, pageCount, ord, ref TotalCount);
 }