protected void Page_Load(object sender, EventArgs e)
 {
     int id = 0;
     if (int.TryParse(Request.QueryString["id"], out id))
     {
         dc = DailyCostOperation.GetDailyCostById(id);
     }
     FormDataBind();
 }
Exemple #2
0
 public PaginationQueryResult<DailyCost> GetDailyCostByCompanyId(PaginationQueryCondition condition, int compId)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@company_id", compId)
     };
     PaginationQueryResult<DailyCost> result = new PaginationQueryResult<DailyCost>();
     string sql = "SELECT TOP " + condition.PageSize + " id, user_id, company_id, audit_user_id, order_user_id, order_time, create_time, audit_time, encode, money, cost_type_id, remark FROM daily_costs 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 daily_costs WHERE is_delete = 0 AND company_id = @company_id ORDER BY id DESC) AS R )";
     }
     sql += " ORDER BY id DESC; SELECT COUNT(*) FROM daily_costs WHERE is_delete = 0 AND company_id = @company_id ";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             DailyCost dc = new DailyCost();
             dc.Id = dr.GetInt32(0);
             dc.UserId = dr.GetInt32(1);
             User user = UserOperation.GetUserById(dc.UserId);
             dc.Username = user.RealName;
             dc.DepartmentName = DepartmentOperation.GetDepartmentById(user.DepartmentId).Name;
             dc.CompanyId = dr.GetInt32(2);
             Company company = CompanyOperation.GetCompanyById(dc.CompanyId);
             dc.CompanyName = company.Name;
             if (!dr.IsDBNull(3))
             {
                 dc.AuditUserId = dr.GetInt32(3);
             }
             dc.OrderUserId = dr.GetInt32(4);
             user = UserOperation.GetUserById(dc.OrderUserId);
             dc.OrderUserName = user.RealName;
             dc.OrderTime = dr.GetDateTime(5);
             dc.CreateTime = dr.GetDateTime(6);
             if (!dr.IsDBNull(7))
             {
                 dc.AuditTime = dr.GetDateTime(7);
             }
             dc.Encode = dr.GetString(8);
             dc.Money = dr.GetDecimal(9);
             dc.CostTypeId = dr.GetInt32(10);
             CostType ct = CostTypeOperation.GetCostTypeById(dc.CostTypeId);
             dc.CostType = ct.Name;
             dc.Remark = dr.GetString(11);
             result.Results.Add(dc);
         }
         dr.NextResult();
         while (dr.Read())
         {
             result.TotalCount = dr.GetInt32(0);
         }
     }
     return result;
 }
Exemple #3
0
        public void CreateDailyCost(DailyCost dc)
        {
            SqlParameter[] param = new SqlParameter[] {
                SqlUtilities.GenerateInputIntParameter("@user_id", dc.UserId),
                SqlUtilities.GenerateInputIntParameter("@company_id", dc.CompanyId),
                SqlUtilities.GenerateInputIntParameter("@order_user_id", dc.OrderUserId),
                SqlUtilities.GenerateInputDateTimeParameter("@order_time", dc.OrderTime),
                SqlUtilities.GenerateInputDateTimeParameter("@create_time", dc.CreateTime),
                SqlUtilities.GenerateInputNVarcharParameter("@encode", 50, dc.Encode),
                SqlUtilities.GenerateInputParameter("@money", SqlDbType.Decimal, dc.Money),
                SqlUtilities.GenerateInputIntParameter("@cost_type_id", dc.CostTypeId),
                SqlUtilities.GenerateInputNVarcharParameter("@remark", 500, dc.Remark)
            };

            string sql = "INSERT INTO daily_costs(user_id, company_id, order_user_id, order_time, create_time, encode, money, cost_type_id, remark) VALUES(@user_id, @company_id, @order_user_id, @order_time, @create_time, @encode, @money, @cost_type_id, @remark)";
            SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strOrderTime = Request.Form[txtOrderTime.ID];
        string remark = Request.Form[txtRemark.ID].Trim();
        string strMoney = Request.Form[txtMoney.ID].Trim();

        DateTime orderTime=new DateTime(1999,1,1);
        if (string.IsNullOrEmpty(strOrderTime) || !DateTime.TryParse(strOrderTime, out orderTime))
        {
            lblMsg.Text = "费用产生时间不能为空,且只能为时间格式!";
            return;
        }
        if (string.IsNullOrEmpty(remark) || Validator.IsMatchLessThanChineseCharacter(remark, REMARK_LENGTH))
        {
            lblMsg.Text = "摘要不能为空,且长度不能超过" + REMARK_LENGTH + "个字符!";
            return;
        }
        decimal money = 0;
        if (string.IsNullOrEmpty(strMoney) || !decimal.TryParse(strMoney, out money))
        {
            lblMsg.Text = "金额不能为空,且只能为数字!";
            return;
        }
        DailyCost dc = new DailyCost();
        dc.CostTypeId = int.Parse(ddlCostsType.SelectedItem.Value);
        dc.CompanyId = user.CompanyId;
        dc.CreateTime = DateTime.Now;
        dc.OrderTime = orderTime;
        dc.Encode = StringHelper.GetEncodeNumber("FY");
        dc.OrderUserId = int.Parse(ddlCompanyUsers.SelectedItem.Value);
        dc.Remark = remark;
        dc.Status = DailyCostStatus.WAIT_AUDIT;
        dc.UserId = user.Id;
        dc.Money = money;
        DailyCostOperation.CreateDailyCost(dc);
        lblMsg.Text = "添加成功!";
    }
 public static void CreateDailyCost(DailyCost dc)
 {
     dal.CreateDailyCost(dc);
 }
Exemple #6
0
 public DailyCost GetDailyCostById(int id)
 {
     DailyCost dc = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", id)
     };
     string sql = "SELECT  id, user_id, company_id, audit_user_id, order_user_id, order_time, create_time, audit_time, encode, money, cost_type_id, remark FROM daily_costs WHERE id = @id";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             dc = new DailyCost();
             dc.Id = dr.GetInt32(0);
             dc.UserId = dr.GetInt32(1);
             User user = UserOperation.GetUserById(dc.UserId);
             dc.Username = user.RealName;
             dc.DepartmentName = DepartmentOperation.GetDepartmentById(user.DepartmentId).Name;
             dc.CompanyId = dr.GetInt32(2);
             Company company = CompanyOperation.GetCompanyById(dc.CompanyId);
             dc.CompanyName = company.Name;
             if (!dr.IsDBNull(3))
             {
                 dc.AuditUserId = dr.GetInt32(3);
             }
             dc.OrderUserId = dr.GetInt32(4);
             user = UserOperation.GetUserById(dc.OrderUserId);
             dc.OrderUserName = user.RealName;
             dc.OrderTime = dr.GetDateTime(5);
             dc.CreateTime = dr.GetDateTime(6);
             if (!dr.IsDBNull(7))
             {
                 dc.AuditTime = dr.GetDateTime(7);
             }
             dc.Encode = dr.GetString(8);
             dc.Money = dr.GetDecimal(9);
             dc.CostTypeId = dr.GetInt32(10);
             CostType ct = CostTypeOperation.GetCostTypeById(dc.CostTypeId);
             dc.CostType = ct.Name;
             dc.Remark = dr.GetString(11);
         }
     }
     return dc;
 }