protected void btnImport_Click(object sender, ImageClickEventArgs e)
    {
        string companyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;

        SubSellOrderModel SubSellOrderM = new SubSellOrderModel();
        SubSellOrderM.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
        SubSellOrderM.OrderNo = this.txtOrderNo.Value.Trim();
        SubSellOrderM.Title = this.txtOrderTitle.Value.Trim();
        SubSellOrderM.SendMode = this.ddlSendMode.Value;
        SubSellOrderM.CustName = this.txtCustName.Value.Trim();
        SubSellOrderM.CustTel = this.txtCustTel.Value.Trim();
        SubSellOrderM.CustMobile = this.txtCustMobile.Value.Trim();
        SubSellOrderM.CustAddr = this.txtCustAddr.Value.Trim();
        SubSellOrderM.DeptID = this.hidDeptID.Value;
        SubSellOrderM.Seller = this.hidUserID.Value;
        SubSellOrderM.BusiStatus = this.ddlBusiStatus.Value;
        SubSellOrderM.BillStatus = this.ddlBillStatus.Value; ;

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

        int totalCount = 0;
        DataTable dt = SubSellOrderBus.SelectSubSellOrder(SubSellOrderM, 1, 100000000, "ID desc", EFIndex, EFDesc, ref totalCount);



        //DataTable dt = WorkCenterBus.GetWorkCenterListBycondition(model, 1, 1000000, "ID desc", ref totalCount);

        //导出标题
        string headerTitle = "订单编号|订单主题|发货模式|客户名称|客户联系电话|客户手机号|送货地址|销售分店|业务员|业务状态|单据状态";
        string[] header = headerTitle.Split('|');

        //导出标题所对应的列字段名称
        string columnFiled = "OrderNo|Title|SendModeName|CustName|CustTel|CustMobile|CustAddr|DeptName|SellerName|BusiStatusName|BillStatusName";
        string[] field = columnFiled.Split('|');

        XBase.Common.OutputToExecl.ExportToTable(this.Page, dt, header, field, "销售订单");
    }
        public static SqlCommand SelectSubSellOrder(SubSellOrderModel SubSellOrderM, int pageIndex, int pageCount, string OrderBy, string EFIndex, string EFDesc, ref int totalCount)
        {
            SqlCommand comm = new SqlCommand();

            #region SQL文
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("SELECT A.ID                     ");
            sql.AppendLine("      ,A.CompanyCD              ");
            sql.AppendLine("      ,A.OrderNo                ");
            sql.AppendLine("      ,A.Title                  ");
            sql.AppendLine("      ,A.DeptID                 ");
            sql.AppendLine("      ,isnull(B.DeptName,'') AS DeptName ");
            sql.AppendLine("      ,A.SendMode               ");
            sql.AppendLine(",case A.SendMode when '1' then '分店发货' when '2' then '总部发货' end AS SendModeName            ");
            sql.AppendLine("      ,A.Seller                 ");
            sql.AppendLine("      ,isnull(C.EmployeeName,'') AS SellerName ");
            sql.AppendLine("      ,isnull(A.CustName,'') AS CustName              ");
            sql.AppendLine("      ,isnull(A.CustTel,'') AS  CustTel              ");
            sql.AppendLine("      ,isnull(A.CustMobile,'') AS CustMobile            ");
            sql.AppendLine("      ,isnull(A.CustAddr,'') AS CustAddr              ");
            sql.AppendLine("      ,A.BusiStatus             ");
            sql.AppendLine(",case A.BusiStatus when '1' then '下单' when '2' then '出库' when '3' then '结算' when '4' then '完成' end AS BusiStatusName");
            sql.AppendLine("      ,A.BillStatus             ");
            sql.AppendLine(", case A.BillStatus when '1' then '制单' when '2' then '执行' when '3' then '变更'when '4' then '手工结单'");
            sql.AppendLine("       when '5' then '自动结单' end AS BillStatusName    ");
            sql.AppendLine("  FROM officedba.SubSellOrder AS A");
            sql.AppendLine(" LEFT JOIN officedba.DeptInfo AS B ON A.DeptID=B.ID  ");
            sql.AppendLine(" LEFT JOIN officedba.EmployeeInfo AS C ON A.Seller=C.ID");
            sql.AppendLine(" WHERE 1=1");
            sql.AppendLine(" AND A.CompanyCD = @CompanyCD");
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", SubSellOrderM.CompanyCD));
            if (SubSellOrderM.OrderNo != "")
            {
                sql.AppendLine(" AND A.OrderNo like @OrderNo");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@OrderNo", "%" + SubSellOrderM.OrderNo + "%"));
            }
            if (SubSellOrderM.Title != "")
            {
                sql.AppendLine(" AND A.Title like @Title");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title", "%" + SubSellOrderM.Title + "%"));
            }
            if (SubSellOrderM.SendMode != "0")
            {
                sql.AppendLine(" AND A.SendMode = @SendMode");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@SendMode", SubSellOrderM.SendMode));
            }
            if (SubSellOrderM.CustName != "")
            {
                sql.AppendLine(" AND A.CustName like @CustName");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustName", "%" + SubSellOrderM.CustName + "%"));
            }

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

            if (SubSellOrderM.CustTel != "")
            {
                sql.AppendLine(" AND A.CustTel like @CustTel");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustTel", "%" + SubSellOrderM.CustTel + "%"));
            }
            if (SubSellOrderM.CustAddr != "")
            {
                sql.AppendLine(" AND A.CustAddr like @CustAddr");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustAddr", "%" + SubSellOrderM.CustAddr + "%"));
            }
            if (SubSellOrderM.DeptID != "")
            {
                sql.AppendLine(" AND A.DeptID = @DeptID");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptID", SubSellOrderM.DeptID));
            }
            if (SubSellOrderM.Seller != "")
            {
                sql.AppendLine(" AND A.Seller = @Seller");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Seller", SubSellOrderM.Seller));
            }
            if (SubSellOrderM.BusiStatus != "0")
            {
                sql.AppendLine(" AND A.BusiStatus = @BusiStatus");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BusiStatus", SubSellOrderM.BusiStatus));
            }
            if (SubSellOrderM.BillStatus != "0")
            {
                sql.AppendLine(" AND A.BillStatus = @BillStatus");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", SubSellOrderM.BillStatus));
            }
            #endregion

            comm.CommandText = sql.ToString();

            return comm;
        }
        //更新结算人,结算时间,安装信息,已付款信息
        public static SqlCommand ConfirmSettSubSellOrder(SubSellOrderModel SubSellOrderM)
        {
            SqlCommand comm = new SqlCommand();
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("UPDATE officedba.SubSellOrder     ");
            sql.AppendLine("   SET isOpenbill      =@isOpenbill     ");
            sql.AppendLine("      ,SttlUserID      =@SttlUserID     ");
            sql.AppendLine("      ,SttlDate        =@SttlDate       ");

            sql.AppendLine("      ,BusiStatus      =@BusiStatus     ");
            sql.AppendLine("      ,BillStatus      =@BillStatus     ");
            sql.AppendLine("      ,Closer          =@Closer         ");
            sql.AppendLine("      ,CloseDate       =@CloseDate      ");


            sql.AppendLine("      ,NeedSetup       =@NeedSetup      ");
            sql.AppendLine("      ,PlanSetDate     =@PlanSetDate    ");
            sql.AppendLine("      ,SetDate         =@SetDate        ");
            sql.AppendLine("      ,SetUserInfo       =@SetUserInfo      ");

            sql.AppendLine("      ,PayedTotal      =@PayedTotal     ");
            sql.AppendLine("      ,WairPayTotal    =@WairPayTotal   ");
            sql.AppendLine("      ,ModifiedDate    =@ModifiedDate  ");
            sql.AppendLine("      ,ModifiedUserID  =@ModifiedUserID  ");
            sql.AppendLine(" WHERE ID=@ID                           ");

            comm.Parameters.Add(SqlHelper.GetParameterFromString("@isOpenbill", SubSellOrderM.isOpenbill));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlUserID", SubSellOrderM.SttlUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlDate", SubSellOrderM.SttlDate));

            if (System.Math.Abs(Convert.ToDouble(SubSellOrderM.WairPayTotal)) < 0.01)
            {//结算完成
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BusiStatus", "4"));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", "5"));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Closer", SubSellOrderM.Creator));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@CloseDate", SubSellOrderM.CreateDate));
            }
            else
            {
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BusiStatus", "3"));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", "2"));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Closer", string.Empty));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@CloseDate", string.Empty));
            }

            comm.Parameters.Add(SqlHelper.GetParameterFromString("@NeedSetup", SubSellOrderM.NeedSetup));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PlanSetDate", SubSellOrderM.PlanSetDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SetDate", SubSellOrderM.SetDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SetUserInfo", SubSellOrderM.SetUserInfo));

            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PayedTotal", SubSellOrderM.PayedTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@WairPayTotal", SubSellOrderM.WairPayTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedDate", SubSellOrderM.ModifiedDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", SubSellOrderM.ModifiedUserID));

            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", SubSellOrderM.ID));

            comm.CommandText = sql.ToString();
            return comm;
        }
        public static SqlCommand ConfirmOutSubSellOrder(SubSellOrderModel SubSellOrderM)
        {
            SqlCommand comm = new SqlCommand();

            #region SQL文
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("UPDATE officedba.SubSellOrder     ");
            //发货信息
            sql.AppendLine("   SET PlanOutDate     =@PlanOutDate    ");
            sql.AppendLine("      ,OutDate         =@OutDate        ");
            sql.AppendLine("      ,CarryType       =@CarryType      ");
            sql.AppendLine("      ,BusiStatus      =@BusiStatus     ");
            sql.AppendLine("      ,BillStatus      =@BillStatus     ");
            sql.AppendLine("      ,OutDeptID       =@OutDeptID      ");
            sql.AppendLine("      ,OutUserID       =@OutUserID      ");
            sql.AppendLine("      ,CustAddr        =@CustAddr       ");
            sql.AppendLine("      ,NeedSetup       =@NeedSetup      ");
            sql.AppendLine("      ,PlanSetDate     =@PlanSetDate    ");
            sql.AppendLine("      ,SetDate         =@SetDate        ");
            sql.AppendLine("      ,SetUserInfo       =@SetUserInfo      ");
            sql.AppendLine("      ,SttlUserID      =@SttlUserID     ");
            sql.AppendLine("      ,SttlDate        =@SttlDate       ");
            sql.AppendLine("      ,Closer           =@Closer");
            sql.AppendLine("      ,CloseDate        =@CloseDate");

            //已付余款金额和未付
            sql.AppendLine("      ,PayedTotal      =@PayedTotal     ");
            sql.AppendLine("      ,WairPayTotal    =@WairPayTotal   ");
            sql.AppendLine(" WHERE ID=@ID                           ");
            #endregion

            #region 传参
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PlanOutDate", SubSellOrderM.PlanOutDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutDate", SubSellOrderM.OutDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CarryType", SubSellOrderM.CarryType));
            if (Convert.ToDouble(SubSellOrderM.WairPayTotal) > 0.01)
            {
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BusiStatus", "3"));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", "2"));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Closer", string.Empty));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@CloseDate", string.Empty));
            }
            else
            {
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BusiStatus", "4"));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", "5"));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Closer", SubSellOrderM.Creator));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@CloseDate", SubSellOrderM.CreateDate));
            }
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutDeptID", SubSellOrderM.OutDeptID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutUserID", SubSellOrderM.OutUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustAddr", SubSellOrderM.CustAddr));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@NeedSetup", SubSellOrderM.NeedSetup));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PlanSetDate", SubSellOrderM.PlanSetDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SetDate", SubSellOrderM.SetDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SetUserInfo", SubSellOrderM.SetUserInfo));

            if (Convert.ToDouble(SubSellOrderM.PayedTotal) > 0.01)
            {
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlUserID", SubSellOrderM.Creator));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlDate", SubSellOrderM.CreateDate));
            }
            else
            {
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlUserID", string.Empty));
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlDate", string.Empty));
            }

            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PayedTotal", SubSellOrderM.PayedTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@WairPayTotal", SubSellOrderM.WairPayTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", SubSellOrderM.ID));
            #endregion

            comm.CommandText = sql.ToString();
            return comm;
        }
        public static SqlCommand InsertSubSellOrder(SubSellOrderModel SubSellOrderM)
        {
            SqlCommand comm = new SqlCommand();

            #region SQL文
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("INSERT INTO officedba.SubSellOrder");
            sql.AppendLine("           (CompanyCD             ");
            sql.AppendLine("           ,OrderNo               ");
            sql.AppendLine("           ,Title                 ");
            sql.AppendLine("           ,DeptID                ");
            sql.AppendLine("           ,SendMode              ");
            sql.AppendLine("           ,Seller                ");
            sql.AppendLine("           ,CustName              ");
            sql.AppendLine("           ,CustTel               ");
            sql.AppendLine("           ,CustMobile            ");
            sql.AppendLine("           ,CustAddr              ");
            sql.AppendLine("           ,CurrencyType          ");
            sql.AppendLine("           ,Rate                  ");
            sql.AppendLine("           ,OrderMethod           ");
            sql.AppendLine("           ,TakeType              ");
            sql.AppendLine("           ,PayType               ");
            sql.AppendLine("           ,MoneyType             ");
            sql.AppendLine("           ,OrderDate             ");
            sql.AppendLine("           ,isAddTax              ");
            sql.AppendLine("           ,PlanOutDate           ");
            sql.AppendLine("           ,OutDate               ");
            sql.AppendLine("           ,CarryType             ");
            sql.AppendLine("           ,BusiStatus            ");
            sql.AppendLine("           ,OutDeptID             ");
            sql.AppendLine("           ,OutUserID             ");
            sql.AppendLine("           ,NeedSetup             ");
            sql.AppendLine("           ,PlanSetDate           ");
            sql.AppendLine("           ,SetDate               ");
            sql.AppendLine("           ,SetUserInfo             ");
            sql.AppendLine("           ,TotalPrice            ");
            sql.AppendLine("           ,Tax                   ");
            sql.AppendLine("           ,TotalFee              ");
            sql.AppendLine("           ,Discount              ");
            sql.AppendLine("           ,SaleFeeTotal          ");
            sql.AppendLine("           ,DiscountTotal         ");
            sql.AppendLine("           ,RealTotal             ");
            sql.AppendLine("           ,PayedTotal            ");
            sql.AppendLine("           ,WairPayTotal          ");
            sql.AppendLine("           ,CountTotal            ");
            sql.AppendLine("           ,BillStatus            ");
            sql.AppendLine("           ,Creator               ");
            sql.AppendLine("           ,CreateDate            ");
            sql.AppendLine("           ,Confirmor             ");
            sql.AppendLine("           ,ConfirmDate           ");
            sql.AppendLine("           ,Closer                ");
            sql.AppendLine("           ,CloseDate             ");
            sql.AppendLine("           ,ModifiedDate          ");
            sql.AppendLine("           ,ModifiedUserID        ");
            sql.AppendLine("           ,Attachment            ");
            sql.AppendLine("           ,Remark                ");
            sql.AppendLine("           ,isOpenbill            ");
            sql.AppendLine("           ,SttlUserID            ");
            sql.AppendLine("           ,SttlDate)             ");
            sql.AppendLine("     VALUES(                      ");
            sql.AppendLine("     		@CompanyCD            ");
            sql.AppendLine("           ,@OrderNo              ");
            sql.AppendLine("           ,@Title                ");
            sql.AppendLine("           ,@DeptID               ");
            sql.AppendLine("           ,@SendMode             ");
            sql.AppendLine("           ,@Seller               ");
            sql.AppendLine("           ,@CustName             ");
            sql.AppendLine("           ,@CustTel              ");
            sql.AppendLine("           ,@CustMobile           ");
            sql.AppendLine("           ,@CustAddr             ");
            sql.AppendLine("           ,@CurrencyType         ");
            sql.AppendLine("           ,@Rate                 ");
            sql.AppendLine("           ,@OrderMethod          ");
            sql.AppendLine("           ,@TakeType             ");
            sql.AppendLine("           ,@PayType              ");
            sql.AppendLine("           ,@MoneyType            ");
            sql.AppendLine("           ,@OrderDate            ");
            sql.AppendLine("           ,@isAddTax             ");
            sql.AppendLine("           ,@PlanOutDate          ");
            sql.AppendLine("           ,@OutDate              ");
            sql.AppendLine("           ,@CarryType            ");
            sql.AppendLine("           ,@BusiStatus           ");
            sql.AppendLine("           ,@OutDeptID            ");
            sql.AppendLine("           ,@OutUserID            ");
            sql.AppendLine("           ,@NeedSetup            ");
            sql.AppendLine("           ,@PlanSetDate          ");
            sql.AppendLine("           ,@SetDate              ");
            sql.AppendLine("           ,@SetUserInfo            ");
            sql.AppendLine("           ,@TotalPrice           ");
            sql.AppendLine("           ,@Tax                  ");
            sql.AppendLine("           ,@TotalFee             ");
            sql.AppendLine("           ,@Discount             ");
            sql.AppendLine("           ,@SaleFeeTotal         ");
            sql.AppendLine("           ,@DiscountTotal        ");
            sql.AppendLine("           ,@RealTotal            ");
            sql.AppendLine("           ,@PayedTotal           ");
            sql.AppendLine("           ,@WairPayTotal         ");
            sql.AppendLine("           ,@CountTotal           ");
            sql.AppendLine("           ,@BillStatus           ");
            sql.AppendLine("           ,@Creator              ");
            sql.AppendLine("           ,@CreateDate           ");
            sql.AppendLine("           ,@Confirmor            ");
            sql.AppendLine("           ,@ConfirmDate          ");
            sql.AppendLine("           ,@Closer               ");
            sql.AppendLine("           ,@CloseDate            ");
            sql.AppendLine("           ,@ModifiedDate         ");
            sql.AppendLine("           ,@ModifiedUserID       ");
            sql.AppendLine("           ,@Attachment           ");
            sql.AppendLine("           ,@Remark               ");
            sql.AppendLine("           ,@isOpenbill           ");
            sql.AppendLine("           ,@SttlUserID           ");
            sql.AppendLine("           ,@SttlDate)            ");
            sql.AppendLine("set @IndexID = @@IDENTITY");
            #endregion

            #region 传参
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", SubSellOrderM.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OrderNo", SubSellOrderM.OrderNo));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title", SubSellOrderM.Title));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptID", SubSellOrderM.DeptID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SendMode", SubSellOrderM.SendMode));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Seller", SubSellOrderM.Seller));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustName", SubSellOrderM.CustName));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustTel", SubSellOrderM.CustTel));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustMobile", SubSellOrderM.CustMobile));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustAddr", SubSellOrderM.CustAddr));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CurrencyType", SubSellOrderM.CurrencyType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Rate", SubSellOrderM.Rate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OrderMethod", SubSellOrderM.OrderMethod));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@TakeType", SubSellOrderM.TakeType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PayType", SubSellOrderM.PayType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@MoneyType", SubSellOrderM.MoneyType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OrderDate", SubSellOrderM.OrderDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@isAddTax", SubSellOrderM.isAddTax));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PlanOutDate", SubSellOrderM.PlanOutDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutDate", SubSellOrderM.OutDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CarryType", SubSellOrderM.CarryType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@BusiStatus", SubSellOrderM.BusiStatus));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutDeptID", SubSellOrderM.OutDeptID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutUserID", SubSellOrderM.OutUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@NeedSetup", SubSellOrderM.NeedSetup));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PlanSetDate", SubSellOrderM.PlanSetDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SetDate", SubSellOrderM.SetDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SetUserInfo", SubSellOrderM.SetUserInfo));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@TotalPrice", SubSellOrderM.TotalPrice));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Tax", SubSellOrderM.Tax));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@TotalFee", SubSellOrderM.TotalFee));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Discount", SubSellOrderM.Discount));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SaleFeeTotal", SubSellOrderM.SaleFeeTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@DiscountTotal", SubSellOrderM.DiscountTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@RealTotal", SubSellOrderM.RealTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PayedTotal", SubSellOrderM.PayedTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@WairPayTotal", SubSellOrderM.WairPayTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CountTotal", SubSellOrderM.CountTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", SubSellOrderM.BillStatus));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Creator", SubSellOrderM.Creator));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CreateDate", SubSellOrderM.CreateDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Confirmor", SubSellOrderM.Confirmor));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ConfirmDate", SubSellOrderM.ConfirmDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Closer", SubSellOrderM.Closer));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CloseDate", SubSellOrderM.CloseDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedDate", SubSellOrderM.ModifiedDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", SubSellOrderM.ModifiedUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Attachment", SubSellOrderM.Attachment));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Remark", SubSellOrderM.Remark));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@isOpenbill", SubSellOrderM.isOpenbill));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlUserID", SubSellOrderM.SttlUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlDate", SubSellOrderM.SttlDate));

            SqlParameter IndexID = new SqlParameter("@IndexID", SqlDbType.Int);
            IndexID.Direction = ParameterDirection.Output;
            comm.Parameters.Add(IndexID);
            #endregion

            comm.CommandText = sql.ToString();
            return comm;
        }
        public static SqlCommand UpdateSubSellOrder(SubSellOrderModel SubSellOrderM)
        {
            SqlCommand comm = new SqlCommand();

            #region SQL文
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("UPDATE officedba.SubSellOrder     ");
            sql.AppendLine("   SET CompanyCD       =@CompanyCD      ");
            sql.AppendLine("      ,OrderNo         =@OrderNo        ");
            sql.AppendLine("      ,Title           =@Title          ");
            sql.AppendLine("      ,DeptID          =@DeptID         ");
            sql.AppendLine("      ,SendMode        =@SendMode       ");
            sql.AppendLine("      ,Seller          =@Seller         ");
            sql.AppendLine("      ,CustName        =@CustName       ");
            sql.AppendLine("      ,CustTel         =@CustTel        ");
            sql.AppendLine("      ,CustMobile      =@CustMobile     ");
            sql.AppendLine("      ,CustAddr        =@CustAddr       ");
            sql.AppendLine("      ,CurrencyType    =@CurrencyType   ");
            sql.AppendLine("      ,Rate            =@Rate           ");
            sql.AppendLine("      ,OrderMethod     =@OrderMethod    ");
            sql.AppendLine("      ,TakeType        =@TakeType       ");
            sql.AppendLine("      ,PayType         =@PayType        ");
            sql.AppendLine("      ,MoneyType       =@MoneyType      ");
            sql.AppendLine("      ,OrderDate       =@OrderDate      ");
            sql.AppendLine("      ,isAddTax        =@isAddTax       ");
            sql.AppendLine("      ,PlanOutDate     =@PlanOutDate    ");
            sql.AppendLine("      ,OutDate         =@OutDate        ");
            sql.AppendLine("      ,CarryType       =@CarryType      ");
            sql.AppendLine("      ,BusiStatus      =@BusiStatus     ");
            sql.AppendLine("      ,OutDeptID       =@OutDeptID      ");
            sql.AppendLine("      ,OutUserID       =@OutUserID      ");
            sql.AppendLine("      ,NeedSetup       =@NeedSetup      ");
            sql.AppendLine("      ,PlanSetDate     =@PlanSetDate    ");
            sql.AppendLine("      ,SetDate         =@SetDate        ");
            sql.AppendLine("      ,SetUserInfo       =@SetUserInfo      ");
            sql.AppendLine("      ,TotalPrice      =@TotalPrice     ");
            sql.AppendLine("      ,Tax             =@Tax            ");
            sql.AppendLine("      ,TotalFee        =@TotalFee       ");
            sql.AppendLine("      ,Discount        =@Discount       ");
            sql.AppendLine("      ,SaleFeeTotal    =@SaleFeeTotal   ");
            sql.AppendLine("      ,DiscountTotal   =@DiscountTotal  ");
            sql.AppendLine("      ,RealTotal       =@RealTotal      ");
            sql.AppendLine("      ,PayedTotal      =@PayedTotal     ");
            sql.AppendLine("      ,WairPayTotal    =@WairPayTotal   ");
            sql.AppendLine("      ,CountTotal      =@CountTotal     ");
            sql.AppendLine("      ,BillStatus      =@BillStatus     ");
            sql.AppendLine("      ,Creator         =@Creator        ");
            sql.AppendLine("      ,CreateDate      =@CreateDate     ");
            sql.AppendLine("      ,Confirmor       =@Confirmor      ");
            sql.AppendLine("      ,ConfirmDate     =@ConfirmDate    ");
            sql.AppendLine("      ,Closer          =@Closer         ");
            sql.AppendLine("      ,CloseDate       =@CloseDate      ");
            sql.AppendLine("      ,ModifiedDate    =@ModifiedDate   ");
            sql.AppendLine("      ,ModifiedUserID  =@ModifiedUserID ");
            sql.AppendLine("      ,Attachment      =@Attachment     ");
            sql.AppendLine("      ,Remark          =@Remark         ");
            sql.AppendLine("      ,isOpenbill      =@isOpenbill     ");
            sql.AppendLine("      ,SttlUserID      =@SttlUserID     ");
            sql.AppendLine("      ,SttlDate        =@SttlDate       ");
            sql.AppendLine(" WHERE ID=@ID                           ");
            #endregion

            #region 传参
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", SubSellOrderM.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OrderNo", SubSellOrderM.OrderNo));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title", SubSellOrderM.Title));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptID", SubSellOrderM.DeptID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SendMode", SubSellOrderM.SendMode));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Seller", SubSellOrderM.Seller));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustName", SubSellOrderM.CustName));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustTel", SubSellOrderM.CustTel));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustMobile", SubSellOrderM.CustMobile));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustAddr", SubSellOrderM.CustAddr));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CurrencyType", SubSellOrderM.CurrencyType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Rate", SubSellOrderM.Rate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OrderMethod", SubSellOrderM.OrderMethod));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@TakeType", SubSellOrderM.TakeType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PayType", SubSellOrderM.PayType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@MoneyType", SubSellOrderM.MoneyType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OrderDate", SubSellOrderM.OrderDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@isAddTax", SubSellOrderM.isAddTax));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PlanOutDate", SubSellOrderM.PlanOutDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutDate", SubSellOrderM.OutDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CarryType", SubSellOrderM.CarryType));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@BusiStatus", SubSellOrderM.BusiStatus));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutDeptID", SubSellOrderM.OutDeptID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutUserID", SubSellOrderM.OutUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@NeedSetup", SubSellOrderM.NeedSetup));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PlanSetDate", SubSellOrderM.PlanSetDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SetDate", SubSellOrderM.SetDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SetUserInfo", SubSellOrderM.SetUserInfo));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@TotalPrice", SubSellOrderM.TotalPrice));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Tax", SubSellOrderM.Tax));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@TotalFee", SubSellOrderM.TotalFee));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Discount", SubSellOrderM.Discount));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SaleFeeTotal", SubSellOrderM.SaleFeeTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@DiscountTotal", SubSellOrderM.DiscountTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@RealTotal", SubSellOrderM.RealTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@PayedTotal", SubSellOrderM.PayedTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@WairPayTotal", SubSellOrderM.WairPayTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CountTotal", SubSellOrderM.CountTotal));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", SubSellOrderM.BillStatus));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Creator", SubSellOrderM.Creator));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CreateDate", SubSellOrderM.CreateDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Confirmor", SubSellOrderM.Confirmor));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ConfirmDate", SubSellOrderM.ConfirmDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Closer", SubSellOrderM.Closer));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CloseDate", SubSellOrderM.CloseDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedDate", SubSellOrderM.ModifiedDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", SubSellOrderM.ModifiedUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Attachment", SubSellOrderM.Attachment));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Remark", SubSellOrderM.Remark));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@isOpenbill", SubSellOrderM.isOpenbill));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlUserID", SubSellOrderM.SttlUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SttlDate", SubSellOrderM.SttlDate));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", SubSellOrderM.ID));
            #endregion

            comm.CommandText = sql.ToString();
            return comm;
        }
        /// <summary>
        /// 扩展属性更新命令
        /// </summary>
        /// <param name="model">分店销售订单</param>
        /// <param name="htExtAttr">扩展属性</param>
        /// <returns></returns>
        public static SqlCommand UpdateExtAttr(SubSellOrderModel model, Hashtable htExtAttr)
        {
            SqlCommand sqlcomm = new SqlCommand();
            if (htExtAttr == null || htExtAttr.Count < 1)
            {// 没有属性需要修改
                return null;
            }

            StringBuilder sb = new StringBuilder(" UPDATE officedba.SubSellOrder 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 OrderNo = @OrderNo ";
            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
            sqlcomm.Parameters.Add(SqlHelper.GetParameter("@OrderNo", model.OrderNo));
            sqlcomm.CommandText = strSql;

            return sqlcomm;
        }
 public static DataTable SelectSubSellOrder(SubSellOrderModel SubSellOrderM, int pageIndex, int pageCount, string OrderBy, string EFIndex, string EFDesc, ref int totalCount)
 {
     try
     {
         SqlCommand comm = SubSellOrderDBHelper.SelectSubSellOrder(SubSellOrderM, pageIndex, pageCount, OrderBy, EFIndex, EFDesc, ref totalCount);
         //执行查询
         return SqlHelper.PagerWithCommand(comm, pageIndex, pageCount, OrderBy, ref totalCount);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static bool ConfirmSttlSubSellOrder(SubSellOrderModel SubSellOrderM)
        {
            try
            {
                SqlCommand comm = SubSellOrderDBHelper.ConfirmSettSubSellOrder(SubSellOrderM);
                //获取登陆用户信息
                UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
                //定义返回变量
                bool isSucc = false;
                /* 
                 * 定义日志内容变量 
                 * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
                 * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
                 */

                //执行插入操作
                try
                {
                    isSucc = SqlHelper.ExecuteTransWithCommand(comm);
                }
                catch (Exception ex)
                {
                    //输出日志
                    WriteSystemLog(userInfo, ex);
                }
                //定义变量
                string remark;
                //成功时
                if (isSucc)
                {
                    //设置操作成功标识
                    remark = ConstUtil.LOG_PROCESS_SUCCESS;
                }
                else
                {
                    //设置操作成功标识 
                    remark = ConstUtil.LOG_PROCESS_FAILED;
                }

                LogInfoModel logModel = InitLogInfo(SubSellOrderM.OrderNo);
                //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
                logModel.Element = ConstUtil.LOG_PROCESS_STTL;
                //设置操作成功标识
                logModel.Remark = remark;

                //登陆日志
                LogDBHelper.InsertLog(logModel);
                return isSucc;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#10
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="SubSellOrderM"></param>
        /// <param name="SubSellOrderDetailMList"></param>
        /// <returns></returns>
        public static bool ConfirmOutSubSellOrder(SubSellOrderModel SubSellOrderM, List<SubSellOrderDetailModel> SubSellOrderDetailMList)
        {
            try
            {
                ArrayList lstConfirm = new ArrayList();
                UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
                int id = 0;
                decimal count = 0m;
                if (SubSellOrderM.SendMode == "1")
                {//分店发货
                    //确认时,更新分店存量表
                    foreach (SubSellOrderDetailModel SubSellOrderDetailM in SubSellOrderDetailMList)
                    {
                        #region 添加门店库存流水帐
                        SubStorageAccountModel aModel = new SubStorageAccountModel();
                        aModel.BatchNo = SubSellOrderDetailM.BatchNo;
                        aModel.BillNo = SubSellOrderM.OrderNo;
                        aModel.BillType = 3;
                        aModel.CompanyCD = SubSellOrderDetailM.CompanyCD;
                        aModel.PageUrl = "";
                        if (int.TryParse(SubSellOrderM.Creator, out id))
                        {
                            aModel.Creator = id;
                        }
                        if (int.TryParse(SubSellOrderM.DeptID, out id))
                        {
                            aModel.DeptID = id;
                        }
                        aModel.HappenDate = DateTime.Now;
                        if (int.TryParse(SubSellOrderDetailM.ProductID, out id))
                        {
                            aModel.ProductID = id;
                        }
                        if (decimal.TryParse(SubSellOrderDetailM.UnitPrice, out count))
                        {
                            aModel.Price = count;
                        }
                        if (decimal.TryParse(SubSellOrderDetailM.ProductCount, out count))
                        {
                            aModel.HappenCount = -count;
                        }
                        aModel.PageUrl = SubSellOrderM.Remark;
                        lstConfirm.Add(XBase.Data.Office.SubStoreManager.SubStorageAccountDBHelper.GetCountAndInsertCommand(aModel));
                        #endregion

                        lstConfirm.Add(XBase.Data.Office.LogisticsDistributionManager.StorageProductQueryDBHelper.UpdateProductCount(userInfo.CompanyCD
                            , SubSellOrderDetailM.ProductID, SubSellOrderM.DeptID, SubSellOrderDetailM.BatchNo, -count));
                    }
                }
                else if (SubSellOrderM.SendMode == "2")
                {//总部发货
                    //确认时更新分仓存量表
                    foreach (SubSellOrderDetailModel SubSellOrderDetailM in SubSellOrderDetailMList)
                    {
                        #region 添加库存流水帐

                        XBase.Model.Office.StorageManager.StorageAccountModel sModel = new XBase.Model.Office.StorageManager.StorageAccountModel();
                        sModel.BatchNo = SubSellOrderDetailM.BatchNo;
                        sModel.BillNo = SubSellOrderM.OrderNo;
                        sModel.BillType = 21;
                        sModel.CompanyCD = SubSellOrderDetailM.CompanyCD;
                        if (int.TryParse(SubSellOrderDetailM.StorageID, out id))
                        {
                            sModel.StorageID = id;
                        }
                        if (int.TryParse(SubSellOrderM.Creator, out id))
                        {
                            sModel.Creator = id;
                        }
                        if (int.TryParse(SubSellOrderDetailM.ProductID, out id))
                        {
                            sModel.ProductID = id;
                        }
                        if (decimal.TryParse(SubSellOrderDetailM.UnitPrice, out count))
                        {
                            sModel.Price = count;
                        }
                        if (decimal.TryParse(SubSellOrderDetailM.ProductCount, out count))
                        {
                            sModel.HappenCount = count;
                        }
                        sModel.HappenDate = DateTime.Now;
                        sModel.PageUrl = SubSellOrderM.Remark;
                        lstConfirm.Add(XBase.Data.Office.StorageManager.StorageAccountDBHelper.InsertStorageAccountCommand(sModel, "1"));

                        #endregion

                        // 更新库存
                        lstConfirm.Add(XBase.Data.Office.StorageManager.StorageSearchDBHelper.UpdateProductCount(userInfo.CompanyCD
                            , SubSellOrderDetailM.ProductID, SubSellOrderDetailM.StorageID
                            , SubSellOrderDetailM.BatchNo, -count));
                    }
                }

                //更新发货信息和安装信息
                lstConfirm.Add(SubSellOrderDBHelper.ConfirmOutSubSellOrder(SubSellOrderM));

                //获取登陆用户信息
                //UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
                //定义返回变量
                bool isSucc = false;
                /* 
                 * 定义日志内容变量 
                 * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
                 * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
                 */

                //执行插入操作
                try
                {
                    isSucc = SqlHelper.ExecuteTransWithArrayList(lstConfirm);
                }
                catch (Exception ex)
                {
                    //输出日志
                    WriteSystemLog(userInfo, ex);
                }
                //定义变量
                string remark;
                //成功时
                if (isSucc)
                {
                    //设置操作成功标识
                    remark = ConstUtil.LOG_PROCESS_SUCCESS;
                }
                else
                {
                    //设置操作成功标识 
                    remark = ConstUtil.LOG_PROCESS_FAILED;
                }

                LogInfoModel logModel = InitLogInfo(SubSellOrderM.OrderNo);
                //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
                logModel.Element = ConstUtil.LOG_PROCESS_OUT;
                //设置操作成功标识
                logModel.Remark = remark;

                //登陆日志
                LogDBHelper.InsertLog(logModel);
                return isSucc;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#11
0
        /// <summary>
        /// 销售订单发货确认判断
        /// </summary>
        /// <param name="SubSellOrderM"></param>
        /// <param name="SubSellOrderDetailMList"></param>
        /// <param name="ProductID">负库存产品ID</param>
        /// <returns>返回1 则数量合法,2 则确认后会有负库存,且不允许出现负库存,3 则确认后会有负库存,允许出现负库存</returns>
        public static int CanConfirmOutSubSellOrder(SubSellOrderModel SubSellOrderM, List<SubSellOrderDetailModel> SubSellOrderDetailMList, ref string ProductID)
        {
            try
            {
                int a = 1;
                Dictionary<int, List<string>> dic = new Dictionary<int, List<string>>();

                //判断是总部发货还是分店发货
                if (SubSellOrderM.SendMode == "1")
                {//分店发货
                    foreach (SubSellOrderDetailModel item in SubSellOrderDetailMList)
                    {
                        a = SubSellOrderDBHelper.CanConfirmOutSub(SubSellOrderM.DeptID, item.ProductID, item.ProductCount, item.BatchNo);
                        if (dic.ContainsKey(a))
                        {// 状态存在
                            if (!dic[a].Contains(item.ProductID))
                            {
                                dic[a].Add(item.ProductID);
                            }
                        }
                        else
                        {// 状态不存在
                            dic.Add(a, new List<string>() { item.ProductID });
                        }
                    }

                }
                else if (SubSellOrderM.SendMode == "2")
                {//总部发货
                    foreach (SubSellOrderDetailModel item in SubSellOrderDetailMList)
                    {
                        a = SubSellOrderDBHelper.CanConfirmOutHq(item.StorageID, item.ProductID, item.ProductCount, item.BatchNo);
                        if (dic.ContainsKey(a))
                        {// 状态存在
                            if (!dic[a].Contains(item.ProductID))
                            {
                                dic[a].Add(item.ProductID);
                            }
                        }
                        else
                        {// 状态不存在
                            dic.Add(a, new List<string>() { item.ProductID });
                        }

                    }
                }
                if (dic.ContainsKey(2))
                {
                    a = 2;
                }
                else if (dic.ContainsKey(3))
                {
                    a = 3;
                }
                else
                {
                    a = 1;
                }
                ProductID = string.Join(",", dic[a].ToArray());
                return a;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#12
0
        public static bool InsertSubSellOrder(SubSellOrderModel SubSellOrderM, List<SubSellOrderDetailModel> SubSellOrderDetailMList, out int IndexIDentity, Hashtable htExtAttr)
        {
            ArrayList lstAdd = new ArrayList();

            //主表新增
            SqlCommand AddPri = SubSellOrderDBHelper.InsertSubSellOrder(SubSellOrderM);
            lstAdd.Add(AddPri);

            // 更新扩展属性
            SqlCommand commExtAttr = SubSellOrderDBHelper.UpdateExtAttr(SubSellOrderM, htExtAttr);
            if (commExtAttr != null)
            {
                lstAdd.Add(commExtAttr);
            }

            //明细表新增
            foreach (SubSellOrderDetailModel SubSellOrderDetailM in SubSellOrderDetailMList)
            {
                SqlCommand AddDtl = SubSellOrderDBHelper.InsertSubSellOrderDetail(SubSellOrderDetailM);
                lstAdd.Add(AddDtl);
            }

            //获取登陆用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //定义返回变量
            bool isSucc = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */

            //执行插入操作
            try
            {
                isSucc = SqlHelper.ExecuteTransWithArrayList(lstAdd);
            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }


            //定义变量
            string remark;
            //成功时
            if (isSucc)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
                IndexIDentity = int.Parse(((SqlCommand)AddPri).Parameters["@IndexID"].Value.ToString());
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
                IndexIDentity = 0;
            }

            LogInfoModel logModel = InitLogInfo(SubSellOrderM.OrderNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_INSERT;
            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);
            return isSucc;
        }
示例#13
0
        public static bool UpdateSubSellOrder(SubSellOrderModel SubSellOrderM, List<SubSellOrderDetailModel> SubSellOrderDetailMList, Hashtable htExtAttr)
        {
            ArrayList lstUpdate = new ArrayList();
            //更新主表
            SqlCommand UpdatePri = SubSellOrderDBHelper.UpdateSubSellOrder(SubSellOrderM);
            lstUpdate.Add(UpdatePri);

            // 更新扩展属性
            SqlCommand commExtAttr = SubSellOrderDBHelper.UpdateExtAttr(SubSellOrderM, htExtAttr);
            if (commExtAttr != null)
            {
                lstUpdate.Add(commExtAttr);
            }

            //删除明细
            SqlCommand DeleteDetail = SubSellOrderDBHelper.DeleteSubSellOrderDetail(SubSellOrderM.OrderNo);
            lstUpdate.Add(DeleteDetail);
            //新增明细
            foreach (SubSellOrderDetailModel SubSellOrderDetailM in SubSellOrderDetailMList)
            {
                SqlCommand AddDetail = SubSellOrderDBHelper.InsertSubSellOrderDetail(SubSellOrderDetailM);
                lstUpdate.Add(AddDetail);
            }

            //获取登陆用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //定义返回变量
            bool isSucc = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */

            //执行插入操作
            try
            {
                isSucc = SqlHelper.ExecuteTransWithArrayList(lstUpdate);
            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }
            //定义变量
            string remark;
            //成功时
            if (isSucc)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }

            LogInfoModel logModel = InitLogInfo(SubSellOrderM.OrderNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;
            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);
            return isSucc;
        }