protected void Page_Load(object sender, EventArgs e) { int id = 0; if (int.TryParse(Request.QueryString["id"], out id)) { sr = ShouldReceiveOperation.GetShouldReceiveById(id); } FormDataBind(); }
public void CreateOrderShouldReceive(ShouldReceive sr) { SqlParameter[] param = new SqlParameter[] { SqlUtilities.GenerateInputIntParameter("@client_id",sr.ClientId), SqlUtilities.GenerateInputIntParameter("@order_id", sr.Order.Id), SqlUtilities.GenerateInputNVarcharParameter("@type", 50, sr.Type), SqlUtilities.GenerateInputParameter("@status", SqlDbType.Bit, sr.Status), SqlUtilities.GenerateInputIntParameter("@user_id", sr.UserId), SqlUtilities.GenerateInputIntParameter("@company_id", sr.CompanyId), SqlUtilities.GenerateInputDateTimeParameter("@create_time", sr.CreateTime), SqlUtilities.GenerateInputDateTimeParameter("@receive_time", sr.ReceiveTime), SqlUtilities.GenerateInputNVarcharParameter("@encode", 50, sr.Encode), SqlUtilities.GenerateInputParameter("@money", SqlDbType.Decimal, sr.Money), SqlUtilities.GenerateInputNVarcharParameter("@remark", 500, sr.Remark) }; string sql = "INSERT INTO should_receive(client_id, order_id, type, status, user_id, company_id, create_time, receive_time, encode, money, remark) VALUES(@client_id, @order_id, @type, @status, @user_id, @company_id, @create_time, @receive_time, @encode, @money, @remark)"; SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param); }
protected void btnAuditThrough_Click(object sender, EventArgs e) { btnAuditThrough.Attributes.Add("onclick", "this.disabled=true;"); Client client = order.Client; decimal oldClientBalance = client.Balance; decimal clientMoney = client.Balance + client.Credit; if (clientMoney < order.Costs) { lblMsg.Text = "该客户余额不足,不能审核通过!"; return; } order.Status = OrderStatus.WAIT_CHECK; order.AuditTime = DateTime.Now; order.AuditUserId = user.Id; order.Reason = ""; client.Balance = client.Balance - order.Costs; ClientOperation.UpdateClientBalance(client); OrderOperation.UpdateOrderStatus(order); OrderOperation.UpdateOrderAuditInfo(order); OrderOperation.UpdateOrderReason(order); if (client.Balance >= 0) { ShouldReceive sr = new ShouldReceive(); sr.Remark = ""; sr.Money = order.Costs; sr.ReceiveTime = DateTime.Now; sr.Type = "订单已收"; sr.UserId = user.Id; sr.ClientId = order.Client.Id; sr.CompanyId = user.CompanyId; sr.CreateTime = DateTime.Now; sr.ReceiveTime = order.CreateTime; sr.Order = order; sr.Status = true; sr.Encode = StringHelper.GetEncodeNumber("SK"); ShouldReceiveOperation.CreateOrderShouldReceive(sr); } else { ShouldReceive sr = new ShouldReceive(); sr.Remark = ""; if (oldClientBalance <= 0) { sr.Money = order.Costs; } else { sr.Money = order.Costs - oldClientBalance; ShouldReceive sred = new ShouldReceive(); sred.Remark = ""; sred.Money = oldClientBalance; sred.ReceiveTime = DateTime.Now; sred.Type = "订单已收"; sred.UserId = user.Id; sred.ClientId = order.Client.Id; sred.CompanyId = user.CompanyId; sred.CreateTime = DateTime.Now; sred.ReceiveTime = order.ReceiveDate; sred.Order = order; sred.Status = true; sred.Encode = StringHelper.GetEncodeNumber("SK"); ShouldReceiveOperation.CreateOrderShouldReceive(sred); } sr.ReceiveTime = DateTime.Now; sr.Type = "订单应收"; sr.UserId = user.Id; sr.ClientId = order.Client.Id; sr.CompanyId = user.CompanyId; sr.CreateTime = DateTime.Now; sr.ReceiveTime = order.ReceiveDate; sr.Order = order; sr.Status = false; sr.Encode = StringHelper.GetEncodeNumber("YS"); ShouldReceiveOperation.CreateOrderShouldReceive(sr); } decimal arrearageMoney = 0; string msg = "操作成功!"; if (client.Balance < 0) { if (oldClientBalance <= 0) { arrearageMoney = order.Costs; } else { arrearageMoney = order.Costs - oldClientBalance; } EmailHelper.SendMailForArrearage(company, client, arrearageMoney, out msg); } Response.Write("<script language='javascript' type='text/javascript'>alert('" + msg + "');location.href='AuditOrderList.aspx';</script>"); }
public void UpdateShouldReceive(ShouldReceive sr) { SqlParameter[] param = new SqlParameter[] { SqlUtilities.GenerateInputIntParameter("@id",sr.Id), SqlUtilities.GenerateInputParameter("@money", SqlDbType.Decimal, sr.Money), SqlUtilities.GenerateInputParameter("@status", SqlDbType.Bit, sr.Status), SqlUtilities.GenerateInputNVarcharParameter("@type", 50, sr.Type), SqlUtilities.GenerateInputDateTimeParameter("@receive_time", sr.ReceiveTime), }; string sql = "UPDATE should_receive SET money = @money, status = @status, type = @type, receive_time= @receive_time WHERE id = @id"; SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param); }
public ShouldReceive GetShouldReceivedByOrderId(int orderId) { ShouldReceive sr = null; SqlParameter[] param = new SqlParameter[] { SqlUtilities.GenerateInputIntParameter("@order_id", orderId) }; string sql = "SELECT id, client_id, type, user_id, company_id, create_time, receive_time, encode, money, remark, order_id, status FROM should_receive WHERE order_id = @order_id AND status = 1"; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param)) { while (dr.Read()) { sr = new ShouldReceive(); sr.Id = dr.GetInt32(0); sr.ClientId = dr.GetInt32(1); Client client = ClientOperation.GetClientById(sr.ClientId); sr.ClientName = client.RealName; sr.Type = dr.GetString(2); sr.UserId = dr.GetInt32(3); sr.CompanyId = dr.GetInt32(4); sr.CreateTime = dr.GetDateTime(5); sr.ReceiveTime = dr.GetDateTime(6); sr.Encode = dr.GetString(7); sr.Money = dr.GetDecimal(8); sr.Remark = dr.GetString(9); if (!dr.IsDBNull(10)) { sr.Order = OrderOperation.GetOrderById(dr.GetInt32(10)); } sr.Status = dr.GetBoolean(11); } } return sr; }
public PaginationQueryResult<ShouldReceive> GetShouldReceiveByParameter(PaginationQueryCondition condition, int compId, bool status, DateTime startDate, DateTime endDate) { SqlParameter[] param = new SqlParameter[] { SqlUtilities.GenerateInputIntParameter("@company_id", compId), SqlUtilities.GenerateInputParameter("@status", SqlDbType.Bit, status), SqlUtilities.GenerateInputDateTimeParameter("@start_date", startDate), SqlUtilities.GenerateInputDateTimeParameter("@end_date", endDate) }; DateTime minTime = new DateTime(1999, 1, 1); string sqlParam = " AND status = @status AND company_id = @company_id"; if (startDate > minTime && endDate > minTime) { sqlParam += " AND create_time BETWEEN @start_date AND @end_date"; } else if (startDate > minTime && endDate <= minTime) { sqlParam += " AND create_time >= @start_date "; } else if (startDate <= minTime && endDate > minTime) { sqlParam += " AND create_time <= @end_date"; } PaginationQueryResult<ShouldReceive> result = new PaginationQueryResult<ShouldReceive>(); string sql = "SELECT TOP " + condition.PageSize + " id, client_id, type, user_id, company_id, create_time, receive_time, encode, money, remark, order_id, status FROM should_receive WHERE is_delete = 0" + sqlParam; if (condition.CurrentPage > 1) { sql += " AND id< (SELECT MIN(id) FROM (SELECT TOP " + condition.PageSize * (condition.CurrentPage - 1) + " id FROM should_receive WHERE is_delete = 0 " + sqlParam + " ORDER BY id DESC) AS R )"; } sql += " ORDER BY id DESC; SELECT COUNT(*) FROM should_receive WHERE is_delete = 0 " + sqlParam; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param)) { while (dr.Read()) { ShouldReceive sr = new ShouldReceive(); sr.Id = dr.GetInt32(0); sr.ClientId = dr.GetInt32(1); Client client = ClientOperation.GetClientById(sr.ClientId); sr.ClientName = client.RealName; sr.Type = dr.GetString(2); sr.UserId = dr.GetInt32(3); sr.CompanyId = dr.GetInt32(4); sr.CreateTime = dr.GetDateTime(5); sr.ReceiveTime = dr.GetDateTime(6); sr.Encode = dr.GetString(7); sr.Money = dr.GetDecimal(8); sr.Remark = dr.GetString(9); if (!dr.IsDBNull(10)) { sr.Order = OrderOperation.GetOrderById(dr.GetInt32(10)); } sr.Status = dr.GetBoolean(11); result.Results.Add(sr); } dr.NextResult(); while (dr.Read()) { result.TotalCount = dr.GetInt32(0); } } return result; }
public static void CreateOrderShouldReceive(ShouldReceive sr) { dal.CreateOrderShouldReceive(sr); }
public static void UpdateShouldReceive(ShouldReceive sr) { dal.UpdateShouldReceive(sr); }
public List<ShouldReceive> GetShouldReceiveStatistic(DateTime startDate, DateTime endDate, int companyId, int clientId, int userId) { List<ShouldReceive> result = new List<ShouldReceive>(); SqlParameter[] param = new SqlParameter[] { SqlUtilities.GenerateInputDateTimeParameter("@start_date", startDate), SqlUtilities.GenerateInputDateTimeParameter("@end_date", endDate), SqlUtilities.GenerateInputIntParameter("@client_id", clientId), SqlUtilities.GenerateInputIntParameter("@company_id", companyId), SqlUtilities.GenerateInputIntParameter("@user_id", userId) }; string sqlParam = ""; DateTime minTime = new DateTime(1999, 1, 1); if (startDate > minTime && endDate > minTime) { sqlParam += " AND create_time BETWEEN @start_date AND @end_date"; } else if (startDate > minTime && endDate <= minTime) { sqlParam += " AND create_time >= @start_date "; } else if (startDate <= minTime && endDate > minTime) { sqlParam += " AND create_time <= @end_date"; } if (companyId > 0) { sqlParam += " AND company_id = @company_id"; } if (clientId >= 0) { sqlParam += " AND client_id = @client_id"; } if (userId > 0) { sqlParam += " AND user_id = @user_id"; } string sql = "SELECT client_id, SUM(money) AS money FROM should_receive WHERE is_delete = 0 AND status = 0 " + sqlParam + " GROUP BY client_id"; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param)) { while (dr.Read()) { ShouldReceive sr = new ShouldReceive(); sr.ClientId = dr.GetInt32(0); sr.Money = dr.GetDecimal(1); result.Add(sr); } } return result; }