protected void Page_Load(object sender, EventArgs e)
 {
     int id = 0;
     if (int.TryParse(Request.QueryString["id"], out id))
     {
         ap = AlreadyPaidOperation.GetAlreadyPaidById(id);
     }
     FormDataBind();
 }
Beispiel #2
0
        public void CreateAlreadyPaid(AlreadyPaid ap)
        {
            SqlParameter[] param = new SqlParameter[] {
                SqlUtilities.GenerateInputIntParameter("@payment_method_id",ap.PaymentMethod.Id),
                SqlUtilities.GenerateInputNVarcharParameter("@invoice", 50, ap.Invoice),
                SqlUtilities.GenerateInputIntParameter("@carrier_id",ap.Carrier.Id),
                SqlUtilities.GenerateInputIntParameter("@user_id", ap.User.Id),
                SqlUtilities.GenerateInputIntParameter("@company_id", ap.CompanyId),
                SqlUtilities.GenerateInputDateTimeParameter("@create_time", ap.CreateTime),
                SqlUtilities.GenerateInputDateTimeParameter("@paid_time", ap.PaidTime),
                SqlUtilities.GenerateInputNVarcharParameter("@encode", 50, ap.Encode),
                SqlUtilities.GenerateInputParameter("@money", SqlDbType.Decimal, ap.Money),
                SqlUtilities.GenerateInputNVarcharParameter("@remark", 500, ap.Remark),
                SqlUtilities.GenerateInputDateTimeParameter("@start_time", ap.StartTime),
                SqlUtilities.GenerateInputDateTimeParameter("@end_time", ap.EndTime)
            };

            string sql = "INSERT INTO already_paid(payment_method_id, invoice, carrier_id, user_id, company_id, create_time, paid_time, encode, money, remark, start_time, end_time) VALUES(@payment_method_id, @invoice, @carrier_id, @user_id, @company_id, @create_time, @paid_time, @encode, @money,     @remark, @start_time, @end_time)";
            SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
        }
Beispiel #3
0
 public PaginationQueryResult<AlreadyPaid> GetAlreadyPaidByCompanyId(PaginationQueryCondition condition, int compId)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@company_id", compId)
     };
     PaginationQueryResult<AlreadyPaid> result = new PaginationQueryResult<AlreadyPaid>();
     string sql = "SELECT TOP " + condition.PageSize + " id, payment_method_id, invoice, carrier_id, user_id, company_id, create_time, paid_time, encode, money, remark, start_time, end_time FROM already_paid WHERE is_delete = 0 AND company_id = @company_id";
     if (condition.CurrentPage > 1)
     {
         sql += " AND id< (SELECT MIN(id) FROM (SELECT TOP " + condition.PageSize * (condition.CurrentPage - 1) + " id FROM already_paid WHERE is_delete = 0 AND company_id = @company_id ORDER BY id DESC) AS R )";
     }
     sql += " ORDER BY id DESC; SELECT COUNT(*) FROM already_paid WHERE is_delete = 0 AND company_id = @company_id ";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             AlreadyPaid ap = new AlreadyPaid();
             ap.Id = dr.GetInt32(0);
             ap.PaymentMethod=PaymentMethodOperation.GetPaymentMethodById(dr.GetInt32(1));
             ap.Invoice = dr.GetString(2);
             ap.Carrier = CarrierOperation.GetCarrierById(dr.GetInt32(3));
             ap.User = UserOperation.GetUserById(dr.GetInt32(4));
             ap.CompanyId = dr.GetInt32(5);
             ap.CreateTime = dr.GetDateTime(6);
             ap.PaidTime = dr.GetDateTime(7);
             ap.Encode = dr.GetString(8);
             ap.Money = dr.GetDecimal(9);
             ap.Remark = dr.GetString(10);
             ap.StartTime = dr.GetDateTime(11);
             ap.EndTime = dr.GetDateTime(12);
             result.Results.Add(ap);
         }
         dr.NextResult();
         while (dr.Read())
         {
             result.TotalCount = dr.GetInt32(0);
         }
     }
     return result;
 }
 public static void CreateAlreadyPaid(AlreadyPaid ap)
 {
     dal.CreateAlreadyPaid(ap);
 }
Beispiel #5
0
 public AlreadyPaid GetAlreadyPaidById(int id)
 {
     AlreadyPaid ap = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", id)
     };
     string sql = "SELECT  id, payment_method_id, invoice, carrier_id, user_id, company_id, create_time, paid_time, encode, money, remark, start_time, end_time FROM already_paid WHERE id = @id";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             ap = new AlreadyPaid();
             ap.Id = dr.GetInt32(0);
             ap.PaymentMethod = PaymentMethodOperation.GetPaymentMethodById(dr.GetInt32(1));
             ap.Invoice = dr.GetString(2);
             ap.Carrier = CarrierOperation.GetCarrierById(dr.GetInt32(3));
             ap.User = UserOperation.GetUserById(dr.GetInt32(4));
             ap.CompanyId = dr.GetInt32(5);
             ap.CreateTime = dr.GetDateTime(6);
             ap.PaidTime = dr.GetDateTime(7);
             ap.Encode = dr.GetString(8);
             ap.Money = dr.GetDecimal(9);
             ap.Remark = dr.GetString(10);
             ap.StartTime = dr.GetDateTime(11);
             ap.EndTime = dr.GetDateTime(12);
         }
     }
     return ap;
 }
Beispiel #6
0
    protected void btnConfirmPaid_Click(object sender, EventArgs e)
    {
        string sDate = Request.Form[txtStartDate.ID].Trim();
        string eDate = Request.Form[txtEndDate.ID].Trim();
        if (string.IsNullOrEmpty(sDate) || string.IsNullOrEmpty(eDate))
        {
            Response.Write("<script language='javascript' type='text/javascript'>alert('请指定具体的时间段!');</script>");
            return;
        }
        DateTime startDate = new DateTime(1999, 1, 1);
        DateTime endDate = new DateTime(1999, 1, 1);
        if (!DateTime.TryParse(sDate, out startDate) || !DateTime.TryParse(eDate, out endDate))
        {
            Response.Write("<script language='javascript' type='text/javascript'>alert('请输入正确的时间格式,如:2008-8-8!');</script>");
            return;
        }
        endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);

        if (ddlCarrier.SelectedItem.Value == "")
        {
            Response.Write("<script language='javascript' type='text/javascript'>alert('请指定承运商!');</script>");
            return;
        }

        int carrierId = int.Parse(ddlCarrier.SelectedItem.Value);

        confirmPaidResult = ShouldPayOperation.GetShouldPayByParameters(user.CompanyId, startDate, endDate, carrierId);

        string strPaidTime = Request.Form[txtPaidTime.ID];
        string invoice = Request.Form[txtInvoice.ID].Trim();
        string remark = Request.Form[txtRemark.ID].Trim();
        DateTime paidTime = new DateTime(1999, 1, 1);
        if (string.IsNullOrEmpty(strPaidTime) || !DateTime.TryParse(strPaidTime, out paidTime))
        {
            lblMsg.Text = "付款日期不能为空,且只能为时间格式!";
            return;
        }
        if (string.IsNullOrEmpty(invoice) || Validator.IsMatchLessThanChineseCharacter(invoice, INVOICE_LENGTH))
        {
            lblMsg.Text = "流水号不能为空,且长度不能超过" + INVOICE_LENGTH + "个字符!";
            return;
        }
        if (!string.IsNullOrEmpty(remark) && Validator.IsMatchLessThanChineseCharacter(remark, REMARK_LENGTH))
        {
            lblMsg.Text = "备注长度不能超过" + REMARK_LENGTH + "个字符!";
            return;
        }

        decimal totalMoney = 0;
        Carrier carrier = null;
        foreach (ShouldPay sp in confirmPaidResult)
        {
            ShouldPayOperation.UpdateShouldPayIsPaid(sp.Id);
            carrier = sp.Carrier;
            totalMoney += sp.OrderDetail.SelfTotalCosts;
        }

        AlreadyPaid ap = new AlreadyPaid();
        ap.User = user;
        ap.Remark = remark;
        ap.PaymentMethod = PaymentMethodOperation.GetPaymentMethodById(int.Parse(ddlPaymentMethod.SelectedItem.Value));
        ap.PaidTime = paidTime;
        ap.Money = totalMoney;
        ap.Invoice = invoice;
        ap.Encode = StringHelper.GetEncodeNumber("FK");
        ap.CreateTime = DateTime.Now;
        ap.CompanyId = user.CompanyId;
        ap.Carrier = carrier;
        ap.Account = "";
        ap.StartTime = startDate;
        ap.EndTime = endDate;
        AlreadyPaidOperation.CreateAlreadyPaid(ap);

        Response.Write("<script language='javascript' type='text/javascript'>alert('操作成功!');location.href='AlreadyPaid.aspx';</script>");
    }