Exemplo n.º 1
0
        public UApp SingleById(int?id)
        {
            cn.Open();
            string        cm = $"select * from U_App where UId = {id}";
            SqlCommand    cd = new SqlCommand(cm, cn);
            SqlDataReader r  = cd.ExecuteReader();
            UApp          ml = new UApp();

            while (r.Read())
            {
                ml = new UApp()
                {
                    id             = int.Parse(r.GetValue("id").ToString()),
                    UId            = int.Parse(r.GetValue("UId").ToString()),
                    CreditSum      = double.Parse(r.GetValue("CreditSum").ToString()),
                    CreditGoal     = r.GetValue("CreditGoal").ToString(),
                    CreditDeadLine = double.Parse(r.GetValue("CreditDeadLine").ToString()),
                    Status         = bool.Parse(r.GetValue("Status").ToString()),
                    Pay            = double.Parse(r.GetValue("Pay").ToString()),
                    Done           = bool.Parse(r.GetValue("Done").ToString())
                };
            }
            cn.Close();
            return(ml);
        }
Exemplo n.º 2
0
        public void Update(UApp ua, int?id)
        {
            cn.Open();
            string     cm = $"update U_App set CreditSum={ua.CreditSum}, CreditDeadLine = '{ua.CreditDeadLine}',CreditGoal = '{ua.CreditGoal}'";
            SqlCommand cd = new SqlCommand(cm, cn);

            cd.ExecuteNonQuery();
            cn.Close();
        }
Exemplo n.º 3
0
        public void Add(UApp ua)
        {
            cn.Open();
            string     cm = $"insert into U_App(UId,CreditSum,CreditGoal,CreditDeadLine,Status,Pay,Done) Values({ua.UId},{ua.CreditSum},'{ua.CreditGoal}','{ua.CreditDeadLine}','{ua.Status}',{ua.Pay},'False');";
            SqlCommand cd = new SqlCommand(cm, cn);

            cd.ExecuteNonQuery();
            cn.Close();
        }