Esempio n. 1
0
        public List <Exp_Cat> all()
        {
            SqlCommand cmd = new SqlCommand("All_Exp_Cat", Connection.Get());

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            SqlDataReader  sdr    = cmd.ExecuteReader();
            List <Exp_Cat> expall = new List <Exp_Cat>();

            while (sdr.Read())
            {
                Exp_Cat ex = new Exp_Cat();
                ex.EC_ID = (int)sdr[0];
                ex.Name  = (string)sdr[1];
                expall.Add(ex);
            }
            sdr.Close();
            return(expall);
        }
Esempio n. 2
0
        public List <Expense> expensebyecid()
        {
            SqlCommand cmd = new SqlCommand("byecid_Expense", Connection.Get());

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@ecid", EC_ID);
            SqlDataReader  sdr   = cmd.ExecuteReader();
            List <Expense> exall = new List <Expense>();

            while (sdr.Read())
            {
                Expense e = new Expense();
                e.E_ID   = (int)sdr[0];
                e.Name   = (string)sdr[1];
                e.Amount = (decimal)sdr[2];
                e.Date   = (string)sdr[3];
                e.EC_ID  = (int)sdr[4];
                e.Add_By = (string)sdr[5];
                exall.Add(e);
            }
            sdr.Close();
            Exp_Cat        ec        = new Exp_Cat();
            List <Exp_Cat> allexpcat = ec.all();

            for (int i = 0; i < allexpcat.Count; i++)
            {
                for (int j = 0; j < exall.Count; j++)
                {
                    if (allexpcat[i].EC_ID == exall[j].EC_ID)
                    {
                        exall[j].EC_Name = allexpcat[i].Name;
                        break;
                    }
                }
            }
            return(exall);
        }