Ejemplo n.º 1
0
        public GetPrintByConditionResponse CreateOrUpdatePrintHeaderAndDetail(int CustomerID, string CustomerName, int WarehouseID, string WarehouseName, string Creator, IEnumerable <PreOrderIds> ids, int PrintID, string PrintKey)
        {
            GetPrintByConditionResponse response = new GetPrintByConditionResponse();

            using (SqlConnection conn = new SqlConnection(BaseAccessor._dataBase.ConnectionString))
            {
                try
                {
                    string     message = "";
                    DataSet    ds      = new DataSet();
                    SqlCommand cmd     = new SqlCommand("Proc_CreateOrUpdatePrintHeaderAndDetail", conn); //Proc_WMS_AutomatedOutbound     Proc_WMS_AutomatedOutbound_Total
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@IDS", ids.Select(a => new WMSPreOrderIdsToDb(a)));      //这是声明一个参数 并赋值
                    cmd.Parameters[0].SqlDbType = SqlDbType.Structured;                                   //声明第一个参数的类型
                    cmd.Parameters.AddWithValue("@CustomerID", CustomerID);                               //声明第二个参数  并赋值
                    cmd.Parameters[1].SqlDbType = SqlDbType.Int;                                          // 声明第二个参数的类型
                    cmd.Parameters.AddWithValue("@CustomerName", CustomerName);                           //声明第三个参数
                    cmd.Parameters[2].SqlDbType = SqlDbType.NVarChar;                                     //声明参数类型
                    cmd.Parameters.AddWithValue("@WarehouseID", WarehouseID);                             //声明第二个参数  并赋值
                    cmd.Parameters[3].SqlDbType = SqlDbType.Int;                                          // 声明第二个参数的类型
                    cmd.Parameters.AddWithValue("@WarehouseName", WarehouseName);                         //声明第三个参数
                    cmd.Parameters[4].SqlDbType = SqlDbType.NVarChar;                                     //声明参数类型
                    cmd.Parameters.AddWithValue("@Creator", Creator);                                     //声明第三个参数
                    cmd.Parameters[5].SqlDbType = SqlDbType.NVarChar;                                     //声明参数类型
                    cmd.Parameters.AddWithValue("@PrintID", PrintID);                                     //声明第二个参数  并赋值
                    cmd.Parameters[6].SqlDbType = SqlDbType.Int;                                          // 声明第二个参数的类型
                    cmd.Parameters.AddWithValue("@PrintKey", PrintKey);                                   //声明第三个参数
                    cmd.Parameters[7].SqlDbType = SqlDbType.NVarChar;                                     //声明参数类型
                    //cmd.Parameters.AddWithValue("@Message", message);//声明第四个参数
                    //cmd.Parameters[3].SqlDbType = SqlDbType.NVarChar;//声明参数的类型
                    //cmd.Parameters[3].Direction = ParameterDirection.Output;//声明参数是输出类型
                    //cmd.Parameters[3].Size = 8000;
                    cmd.CommandTimeout = 300;
                    conn.Open();

                    SqlDataAdapter sda = new SqlDataAdapter();
                    sda.SelectCommand = cmd;
                    sda.Fill(ds);//将得到的数据 填充到DataTable中
                    //message = sda.SelectCommand.Parameters["@Message"].Value.ToString();//获得数据库  out出来的参数的值 (并不是由return 而来)
                    conn.Close();

                    response.PrintHeaderCollection = ds.Tables[0].ConvertToEntityCollection <PrintHeader>();
                    response.PrintDetailCollection = ds.Tables[1].ConvertToEntityCollection <PrintDetail>();
                    //return ds.Tables[ds.Tables.Count - 1].ConvertToEntityCollection<DistributionInformation>();
                    //if (ds.Tables.Count > 1)
                    //{
                    //    return ds.Tables[1].ConvertToEntityCollection<DistributionInformation>();
                    //}
                    //else
                    //{
                    //    return ds.Tables[0].ConvertToEntityCollection<DistributionInformation>();
                    //}
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return(response);
        }
Ejemplo n.º 2
0
        public GetPrintByConditionResponse GetPrintHeaderAndDetailByID(int ID)
        {
            GetPrintByConditionResponse response = new GetPrintByConditionResponse();

            DbParam[] dbParams = new DbParam[] {
                new DbParam("@ID", DbType.Int16, ID, ParameterDirection.Input)
            };

            DataSet ds = this.ExecuteDataSet("Proc_WMS_GetPrintHeaderAndDetailByID", dbParams);

            response.PrintHeaderCollection = ds.Tables[0].ConvertToEntityCollection <PrintHeader>();
            response.PrintDetailCollection = ds.Tables[1].ConvertToEntityCollection <PrintDetail>();
            return(response);
        }
Ejemplo n.º 3
0
        public GetPrintByConditionResponse GetPrintHeaderByCondition(PrintHeaderSearchCondition SearchCondition, int pageIndex, int pageSize, out int rowCount)
        {
            GetPrintByConditionResponse response = new GetPrintByConditionResponse();
            string sqlWhere     = this.GenGetPrintHeaderWhere(SearchCondition);
            int    tempRowCount = 0;

            DbParam[] dbParams = new DbParam[] {
                new DbParam("@Where", DbType.String, sqlWhere, ParameterDirection.Input),
                new DbParam("@PageIndex", DbType.Int32, pageIndex, ParameterDirection.Input),
                new DbParam("@PageSize", DbType.Int32, pageSize, ParameterDirection.Input),
                new DbParam("@RowCount", DbType.Int32, tempRowCount, ParameterDirection.Output)
            };

            DataSet ds = this.ExecuteDataSet("Proc_WMS_GetPrintHeaderByCondition", dbParams);

            rowCount = (int)dbParams[3].Value;
            response.PrintHeaderCollection = ds.Tables[0].ConvertToEntityCollection <PrintHeader>();
            return(response);
        }