Beispiel #1
0
    public static List <JieSuanInfo> ReadList(string whereStr)
    {
        List <JieSuanInfo> list        = new List <JieSuanInfo>();
        Database           database    = new Database();
        DataView           defaultView = database.RunProc("select * from JieSuan " + whereStr).Tables[0].DefaultView;

        for (int i = 0; i < defaultView.Count; i++)
        {
            list.Add(JieSuanInfo.Read(int.Parse(defaultView[i]["id"].ToString())));
        }
        database.Dispose();
        return(list);
    }
Beispiel #2
0
    public static JieSuanInfo Read(int id)
    {
        JieSuanInfo     result          = null;
        Database        database        = new Database();
        MySqlDataReader oleDbDataReader = database.RunProcGetReader("select * from JieSuan where id=" + id);

        while (oleDbDataReader.Read())
        {
            result = new JieSuanInfo(int.Parse(oleDbDataReader.GetValue(0).ToString()), int.Parse(oleDbDataReader.GetValue(1).ToString()), oleDbDataReader.GetValue(2).ToString(), double.Parse(oleDbDataReader.GetValue(3).ToString()), double.Parse(oleDbDataReader.GetValue(4).ToString()), double.Parse(oleDbDataReader.GetValue(5).ToString()), double.Parse(oleDbDataReader.GetValue(6).ToString()), double.Parse(oleDbDataReader.GetValue(7).ToString()), double.Parse(oleDbDataReader.GetValue(8).ToString()), DateTime.Parse(oleDbDataReader.GetValue(9).ToString()), int.Parse(oleDbDataReader.GetValue(10).ToString()));
        }
        oleDbDataReader.Close();
        database.Dispose();
        return(result);
    }
    protected void bt_jieSuan_Click(object sender, EventArgs e)
    {
        DateTime dateTime = DateTime.Parse(this.lb_lastJieSuanDate.Text);
        DateTime addDate  = default(DateTime);
        int      num      = int.Parse(this.hf_lastJieSuanId.Value) + 1;

        if (DateTime.TryParse(this.newJieSuanDate.Text, out addDate))
        {
            this.db.RunNonQurey(string.Concat(new object[]
            {
                "insert into JieSuanDate(JieSuanId,AddDate)values(",
                num,
                ",'",
                DateTime.Parse(this.newJieSuanDate.Text),
                "')"
            }));
            ConfigInfo      configInfo      = ConfigInfo.Read(1);
            MySqlDataReader mySqlDataReader = this.db.RunProcGetReader(string.Concat(new string[]
            {
                "select userId, username,sum(duipengjiang) as duipengjiang,sum(jintie) as jintie,sum(allJiangjin) as allJiangjin from JiangJin where addDate>'",
                dateTime.ToString(),
                "' And addDate<='",
                addDate.ToString(),
                "' group by username,userId"
            }));
            while (mySqlDataReader.Read())
            {
                double      fenHong     = Math.Round(double.Parse(mySqlDataReader["allJiangJin"].ToString()) * (double)configInfo.FenHong * 0.01, 2);
                double      kouShui     = Math.Round(double.Parse(mySqlDataReader["allJiangJin"].ToString()) * configInfo.KouShui * 0.01, 2);
                double      num2        = Math.Round(this.GetShiJiang(mySqlDataReader["allJiangJin"].ToString(), mySqlDataReader["userId"].ToString()), 2);
                JieSuanInfo jieSuanInfo = new JieSuanInfo(0, int.Parse(mySqlDataReader["userId"].ToString()), mySqlDataReader["username"].ToString(), double.Parse(mySqlDataReader["duipengjiang"].ToString()), double.Parse(mySqlDataReader["jintie"].ToString()), double.Parse(mySqlDataReader["allJiangJin"].ToString()), fenHong, kouShui, num2, addDate, num);
                jieSuanInfo.Insert();
                MemberInfo memberInfo = MemberInfo.Read(int.Parse(mySqlDataReader["userId"].ToString()));
                memberInfo.JiangJin += num2;
                memberInfo.Update();
            }
            mySqlDataReader.Close();
            this.db.Dispose();
            this.BindData();
            return;
        }
        this.Page.ClientScript.RegisterStartupScript(base.GetType(), "wrong", "alert('日期格式错误,请检查日期格式!');", true);
        this.BindData();
    }