コード例 #1
0
ファイル: PostPlanDAL.cs プロジェクト: sd1362168638/XSEMS
 public List<PostPlan> GetPostPlan()
 {
     List<PostPlan> result = new List<PostPlan>();
     string sql = "SELECT id, carrier_id, company_id, package_count, weight, depot_id, user_id, create_time FROM post_plans WHERE is_delete = 0";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, null))
     {
         while (dr.Read())
         {
             PostPlan pp = new PostPlan();
             pp.Id = dr.GetInt32(0);
             Carrier carrier = new CarrierDAL().GetCarrierById(dr.GetInt32(1));
             pp.Carrier = carrier;
             pp.CompanyId = dr.GetInt32(2);
             pp.PackageCount = dr.GetInt32(3);
             pp.Weight = dr.GetDecimal(4);
             Depot depot = new DepotDAL().GetDepotById(dr.GetInt32(5));
             pp.Depot = depot;
             User user = new UserDAL().GetUserById(dr.GetInt32(6));
             pp.User = user;
             pp.CreateTime = dr.GetDateTime(7);
             result.Add(pp);
         }
     }
     return result;
 }
コード例 #2
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        string strPackageCount = Request.Form[txtPackageCount.ID].Trim();
        string strWeight = Request.Form[txtWeight.ID].Trim();

        int packageCount = 0;
        if (string.IsNullOrEmpty(strPackageCount) || !int.TryParse(strPackageCount, out packageCount))
        {
            lblMsg.Text = "发件包裹数量不能为空,且只能为数字!";
            return;
        }

        decimal weight = 0;
        if (string.IsNullOrEmpty(strWeight) || !decimal.TryParse(strWeight, out weight))
        {
            lblMsg.Text = "总重量不能为空,且只能为数字!";
            return;
        }
        PostPlan pp = new PostPlan();
        pp.CreateTime = DateTime.Now;
        pp.CompanyId = user.CompanyId;
        Carrier carrier = CarrierOperation.GetCarrierById(int.Parse(ddlCarrier.SelectedItem.Value));
        pp.Carrier = carrier;
        Depot depot = DepotOperation.GetDepotById(int.Parse(ddlDepot.SelectedItem.Value));
        pp.Depot = depot;
        pp.PackageCount = packageCount;
        pp.User = user;
        pp.Weight = weight;
        PostPlanOperation.CreatePostPlan(pp);
        Response.Write("<script language='javascript' type='text/javascript'>alert('添加成功!');location.href='PostPlanList.aspx';</script>");
    }
コード例 #3
0
ファイル: PostPlanDAL.cs プロジェクト: sd1362168638/XSEMS
 public void CreatePostPlan(PostPlan pp)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@carrier_id", pp.Carrier.Id),
         SqlUtilities.GenerateInputIntParameter("@company_id", pp.CompanyId),
         SqlUtilities.GenerateInputIntParameter("@package_count", pp.PackageCount),
         SqlUtilities.GenerateInputParameter("@weight", SqlDbType.Decimal, pp.Weight),
         SqlUtilities.GenerateInputIntParameter("@depot_id", pp.Depot.Id),
         SqlUtilities.GenerateInputIntParameter("@user_id", pp.User.Id),
         SqlUtilities.GenerateInputDateTimeParameter("@create_time", pp.CreateTime)
     };
     string sql = "INSERT INTO post_plans(carrier_id, company_id, package_count, weight, depot_id, user_id, create_time) VALUES(@carrier_id,         @company_id, @package_count, @weight, @depot_id, @user_id, @create_time)";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }
コード例 #4
0
ファイル: PostPlan.aspx.cs プロジェクト: sd1362168638/XSEMS
 protected void Page_Load(object sender, EventArgs e)
 {
     int id = 0;
     if (int.TryParse(Request.QueryString["id"], out id))
     {
         pp = PostPlanOperation.GetPostPlanById(id);
     }
     AdminCookie cookie = (AdminCookie)RuleAuthorizationManager.GetCurrentSessionObject(Context, true);
     user = UserOperation.GetUserByUsername(cookie.Username);
     List<Depot> result = DepotOperation.GetDepotByCompanyId(pp.CompanyId);
     if (!IsPostBack)
     {
         ddlDepot.DataSource = result;
         ddlDepot.DataTextField = "Name";
         ddlDepot.DataValueField = "Id";
         ddlDepot.DataBind();
         FormDataBind();
     }
 }
コード例 #5
0
ファイル: PostPlanDAL.cs プロジェクト: sd1362168638/XSEMS
 public PaginationQueryResult<PostPlan> GetPostPlanByCompanyId(PaginationQueryCondition condition, int compId)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@company_id", compId)
     };
     PaginationQueryResult<PostPlan> result = new PaginationQueryResult<PostPlan>();
     string sql = "SELECT TOP " + condition.PageSize + " id, carrier_id, company_id, package_count, weight, depot_id, user_id, create_time FROM post_plans WHERE company_id = @company_id AND is_delete = 0";
     if (condition.CurrentPage > 1)
     {
         sql += " AND id < (SELECT MIN(id) FROM (SELECT TOP " + condition.PageSize*(condition.CurrentPage - 1) + " id FROM post_plans WHERE company_id = @company_id AND is_delete = 0 ORDER BY id DESC) AS P)";
     }
     sql += " ORDER BY id DESC; SELECT COUNT(*) FROM post_plans WHERE company_id = @company_id AND is_delete = 0";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             PostPlan pp = new PostPlan();
             pp.Id = dr.GetInt32(0);
             Carrier carrier = new CarrierDAL().GetCarrierById(dr.GetInt32(1));
             pp.Carrier = carrier;
             pp.CompanyId = dr.GetInt32(2);
             pp.PackageCount = dr.GetInt32(3);
             pp.Weight = dr.GetDecimal(4);
             Depot depot = new DepotDAL().GetDepotById(dr.GetInt32(5));
             pp.Depot = depot;
             User user = new UserDAL().GetUserById(dr.GetInt32(6));
             pp.User = user;
             pp.CreateTime = dr.GetDateTime(7);
             result.Results.Add(pp);
         }
         dr.NextResult();
         while (dr.Read())
         {
             result.TotalCount = dr.GetInt32(0);
         }
     }
     return result;
 }
コード例 #6
0
 public static void UpdatePostPlan(PostPlan pp)
 {
     dal.UpdatePostPlan(pp);
 }
コード例 #7
0
 public static void CreatePostPlan(PostPlan pp)
 {
     dal.CreatePostPlan(pp);
 }
コード例 #8
0
ファイル: PostPlanDAL.cs プロジェクト: sd1362168638/XSEMS
 public void UpdatePostPlan(PostPlan pp)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", pp.Id),
         SqlUtilities.GenerateInputIntParameter("@carrier_id", pp.Carrier.Id),
         SqlUtilities.GenerateInputIntParameter("@package_count", pp.PackageCount),
         SqlUtilities.GenerateInputParameter("@weight", SqlDbType.Decimal, pp.Weight),
         SqlUtilities.GenerateInputIntParameter("@depot_id", pp.Depot.Id),
         SqlUtilities.GenerateInputIntParameter("@user_id", pp.User.Id)
     };
     string sql = "UPDATE post_plans SET carrier_id = @carrier_id, package_count = @package_count, weight = @weight, depot_id = @depot_id, user_id = @user_id WHERE id = @id";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }
コード例 #9
0
ファイル: PostPlanDAL.cs プロジェクト: sd1362168638/XSEMS
 public PostPlan GetPostPlanById(int id)
 {
     PostPlan pp = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", id)
     };
     string sql = "SELECT id, carrier_id, company_id, package_count, weight, depot_id, user_id, create_time FROM post_plans WHERE id = @id";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             pp = new PostPlan();
             pp.Id = dr.GetInt32(0);
             Carrier carrier = new CarrierDAL().GetCarrierById(dr.GetInt32(1));
             pp.Carrier = carrier;
             pp.CompanyId = dr.GetInt32(2);
             pp.PackageCount = dr.GetInt32(3);
             pp.Weight = dr.GetDecimal(4);
             Depot depot = new DepotDAL().GetDepotById(dr.GetInt32(5));
             pp.Depot = depot;
             User user = new UserDAL().GetUserById(dr.GetInt32(6));
             pp.User = user;
             pp.CreateTime = dr.GetDateTime(7);
         }
     }
     return pp;
 }