public void update(TTravelExpenseApplication t)
        {
            string sql = "Update tTravel_Expense_Application SET ";

            sql += "cDepartment=@K_CDepartment,";
            sql += "cEmployeeId=@K_CEmployeeId,";
            sql += "cReason=@K_CReason,";
            sql += "cApplyDate=@K_CApplyDate,";
            sql += "cTravelStartTime=@K_CTravelStartTime,";
            sql += "cTravelEndTime=@K_CTravelEndTime,";
            sql += "cAmont=@K_CAmont,";
            sql += "cCheckStatus=@K_CCheckStatus";
            sql += " WHERE cApplyNumber=@K_CApplyNumber";

            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("K_CDepartment", (object)t.CDepartment));
            list.Add(new SqlParameter("K_CEmployeeId", (object)t.CEmployeeId));
            list.Add(new SqlParameter("K_CReason", (object)t.CReason));
            list.Add(new SqlParameter("K_CApplyDate", (object)t.CApplyDate));
            list.Add(new SqlParameter("K_CTravelStartTime", (object)t.CTravelStartTime));
            list.Add(new SqlParameter("K_CTravelEndTime", (object)t.CTravelEndTime));
            list.Add(new SqlParameter("K_CAmont", (object)t.CAmont));
            list.Add(new SqlParameter("K_CCheckStatus", (object)t.CCheckStatus));
            list.Add(new SqlParameter("K_CApplyNumber", (object)t.CApplyNumber));

            execusteSql(sql, list);
        }
        public void delete(TTravelExpenseApplication t)
        {
            string sql = "DELETE FROM tTravel_Expense_Application WHERE cApplyNumber=@K_CApplyNumber";
            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("K_CApplyNumber", (object)t.CApplyNumber));
            execusteSql(sql, list);
        }
Exemple #3
0
        public IActionResult Create(TTravelExpenseApplication t)
        {
            dbMyCompanyContext db = new dbMyCompanyContext();

            db.TTravelExpenseApplications.Add(t);
            db.SaveChanges();
            return(View());
        }
        private List <TTravelExpenseApplication> getBysql(string sql, List <SqlParameter> paras)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = @"Data Source =.; Initial Catalog = dbMyCompany; Integrated Security = True";
            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);

            if (paras != null)
            {
                foreach (SqlParameter p in paras)
                {
                    cmd.Parameters.Add(p);
                }
            }
            SqlDataReader reader = cmd.ExecuteReader();
            List <TTravelExpenseApplication> list = new List <TTravelExpenseApplication>();

            while (reader.Read())
            {
                TTravelExpenseApplication travel = new TTravelExpenseApplication()
                {
                    //todo Reina
                    //CDepartment = (int)reader["CDepartment"],
                    CEmployeeId      = (int)reader["CEmployeeId"],
                    CReason          = reader["CReason"].ToString(),
                    CApplyDate       = ((DateTime)reader["CApplyDate"]),
                    CTravelStartTime = ((DateTime)reader["CTravelStartTime"]),
                    CTravelEndTime   = ((DateTime)reader["CTravelEndTime"]),
                    CAmont           = (decimal)reader["CAmont"],
                    CCheckStatus     = (int)reader["CCheckStatus"]
                };
                list.Add(travel);
            }
            con.Close();
            return(list);
        }
        public void instert(TTravelExpenseApplication t)
        {
            string sql = "INSERT INTO tTravel_Expense_Application(";

            sql += "cDepartment,";
            sql += "cEmployeeId,";
            sql += "cReason,";
            sql += "cApplyDate,";
            sql += "cTravelStartTime,";
            sql += "cTravelEndTime,";
            sql += "cAmont,";
            sql += "cCheckStatus";
            sql += ")VALUES(";
            sql += "@K_CDepartment,";
            sql += "@K_CEmployeeId,";
            sql += "@K_CReason,";
            sql += "@K_CApplyDate,";
            sql += "@K_CTravelStartTime,";
            sql += "@K_CTravelEndTime,";
            sql += "@K_CAmont,";
            sql += "@K_CCheckStatus";

            List <SqlParameter> list = new List <SqlParameter>();

            list.Add(new SqlParameter("K_CDepartment", (object)t.CDepartment));
            list.Add(new SqlParameter("K_CEmployeeId", (object)t.CEmployeeId));
            list.Add(new SqlParameter("K_CReason", (object)t.CReason));
            list.Add(new SqlParameter("K_CApplyDate", (object)t.CApplyDate));
            list.Add(new SqlParameter("K_CTravelStartTime", (object)t.CTravelStartTime));
            list.Add(new SqlParameter("K_CTravelEndTime", (object)t.CTravelEndTime));
            list.Add(new SqlParameter("K_CAmont", (object)t.CAmont));
            list.Add(new SqlParameter("K_CCheckStatus", (object)t.CCheckStatus));
            list.Add(new SqlParameter("K_CApplyNumber", (object)t.CApplyNumber));

            execusteSql(sql, list);
        }