Esempio n. 1
0
        //CREATE EVENT
        public static string CreateEvent(EventViewModel paramDataEvent)
        {
            string latestSaveCode = string.Empty;

            using (var db = new MarkomApplicationDBEntities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        t_event c = new t_event();
                        c.code         = EventCode();
                        c.event_name   = paramDataEvent.eventName;
                        c.place        = paramDataEvent.place;
                        c.start_date   = paramDataEvent.startDate;
                        c.end_date     = paramDataEvent.endDate;
                        c.budget       = paramDataEvent.budget;
                        c.status       = paramDataEvent.status;
                        c.is_delete    = paramDataEvent.isDelete;
                        c.request_by   = paramDataEvent.requestBy;
                        c.request_date = paramDataEvent.requestDate;
                        c.note         = paramDataEvent.note;
                        c.create_by    = paramDataEvent.createBy;
                        c.create_date  = paramDataEvent.createDate;

                        db.t_event.Add(c);
                        db.SaveChanges();
                        dbContextTransaction.Commit();

                        //get latest save code
                        latestSaveCode = c.code;
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                        dbContextTransaction.Rollback();
                    }
                }
            }

            return(latestSaveCode);
        }
        //public static List<EmployeeViewModel> GetListEmployee(EmployeeViewModel paramSearch)
        //{
        //    List<EmployeeViewModel> result = new List<EmployeeViewModel>();

        //    using (var context = new MarkomApplicationDBEntities())
        //    {
        //        var res = context.spEmployeeSearch(paramSearch.code, paramSearch.fullName,paramSearch.mCompanyId, paramSearch.createDate2, paramSearch.createBy);

        //        List<EmployeeViewModel> comList = res.Select(c => new EmployeeViewModel
        //        {
        //            id = c.id,
        //            code = c.employee_number,
        //            firstName = c.first_name,
        //            lastName = c.last_name,
        //            mCompanyId = c.m_company_id,
        //            companyName = c.name,
        //            createDate = c.create_date,
        //            createBy = c.create_by
        //        }).ToList();

        //        result = comList;
        //    }

        //    return result;
        //}

        //CREATE EMPLOYEE


        public static string CreateEmployee(EmployeeViewModel paramDataEmployee)
        {
            string latestSaveCode = string.Empty;

            using (var db = new MarkomApplicationDBEntities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        m_employee c = new m_employee();
                        c.employee_number = paramDataEmployee.code;
                        c.first_name      = paramDataEmployee.firstName;
                        c.last_name       = paramDataEmployee.lastName;
                        c.m_company_id    = paramDataEmployee.mCompanyId;
                        c.email           = paramDataEmployee.email;
                        c.is_delete       = paramDataEmployee.isDelete;
                        c.create_by       = paramDataEmployee.createBy;
                        c.create_date     = paramDataEmployee.createDate;

                        db.m_employee.Add(c);
                        db.SaveChanges();
                        dbContextTransaction.Commit();

                        //get latest save code
                        latestSaveCode = c.employee_number;
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                        dbContextTransaction.Rollback();
                        //throw;
                    }
                }
            }

            return(latestSaveCode);
        }
        public static string CreateCompany(CompanyViewModel paramDataCompany)
        {
            string latestSaveCode = string.Empty;

            using (var db = new MarkomApplicationDBEntities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        m_company c = new m_company();
                        c.code        = CompanyCode();
                        c.name        = paramDataCompany.name;
                        c.address     = paramDataCompany.address;
                        c.phone       = paramDataCompany.phone;
                        c.email       = paramDataCompany.email;
                        c.is_delete   = paramDataCompany.isDelete;
                        c.create_by   = paramDataCompany.createBy;
                        c.create_date = paramDataCompany.createDate;

                        db.m_company.Add(c);
                        db.SaveChanges();
                        dbContextTransaction.Commit();

                        //get latest save code
                        latestSaveCode = c.code;
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                        dbContextTransaction.Rollback();
                        //throw;
                    }
                }
            }

            return(latestSaveCode);
        }
Esempio n. 4
0
        public static string CreateMenu(MenuViewModel paramDataMenu)
        {
            string latestSaveCode = string.Empty;

            using (var db = new MarkomApplicationDBEntities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        m_menu c = new m_menu();
                        c.code        = MenuCode();
                        c.name        = paramDataMenu.name;
                        c.controller  = paramDataMenu.controller;
                        c.parent_id   = paramDataMenu.parentId;
                        c.is_delete   = paramDataMenu.isDelete;
                        c.create_by   = paramDataMenu.createBy;
                        c.create_date = paramDataMenu.createDate;

                        db.m_menu.Add(c);
                        db.SaveChanges();
                        dbContextTransaction.Commit();

                        //get latest save code
                        latestSaveCode = c.code;
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                        dbContextTransaction.Rollback();
                        //throw;
                    }
                }
            }

            return(latestSaveCode);
        }
Esempio n. 5
0
        public static string CreateSouvenir(SouvenirViewModel paramDataSou)
        {
            string latestSaveCode = string.Empty;

            using (var db = new MarkomApplicationDBEntities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        m_souvenir c = new m_souvenir();
                        c.code        = SouvenirCode();
                        c.name        = paramDataSou.name;
                        c.m_unit_id   = paramDataSou.mUnitId;
                        c.description = paramDataSou.description;
                        c.is_delete   = paramDataSou.isDelete;
                        c.create_by   = paramDataSou.createBy;
                        c.create_date = paramDataSou.createDate;

                        db.m_souvenir.Add(c);
                        db.SaveChanges();
                        dbContextTransaction.Commit();

                        //get latest save code
                        latestSaveCode = c.code;
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                        dbContextTransaction.Rollback();
                        //throw;
                    }
                }
            }

            return(latestSaveCode);
        }
Esempio n. 6
0
        public static string CreateProduct(ProductViewModel paramDataProd)
        {
            string latestSaveCode = string.Empty;

            using (var db = new MarkomApplicationDBEntities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        m_product c = new m_product();
                        c.code        = ProductCode();
                        c.name        = paramDataProd.name;
                        c.description = paramDataProd.description;
                        c.is_delete   = paramDataProd.isDelete;
                        c.create_by   = paramDataProd.createBy;
                        c.create_date = paramDataProd.createDate;

                        db.m_product.Add(c);
                        db.SaveChanges();
                        dbContextTransaction.Commit();

                        //get latest save code
                        latestSaveCode = c.code;
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                        dbContextTransaction.Rollback();
                        //throw;
                    }
                }
            }

            return(latestSaveCode);
        }