Exemplo n.º 1
0
        public IHttpActionResult GetMenu(string username)
        {
            var            _unitCode = _service.GetCurrentUnitCode();
            var            result    = new TransferObj <List <ChoiceObj> >();
            List <AU_MENU> lstMenu   = new List <AU_MENU>();

            lstMenu = _service.Repository.DbSet.Where(x => x.TrangThai == 10).OrderBy(x => x.Sort).ToList();
            //if (username.Equals("admin"))
            //{

            //}
            //else
            //{
            //    lstMenu = _service.GetAllForStarting(username, _unitCode);
            //}
            result.Data = new List <ChoiceObj>();
            if (lstMenu != null)
            {
                lstMenu.ForEach(x =>
                {
                    ChoiceObj obj = new ChoiceObj()
                    {
                        Id     = x.Id,
                        Text   = x.Title,
                        Parent = x.MenuIdCha,
                        Value  = x.MenuId,
                    };
                    result.Data.Add(obj);
                });
            }
            return(Ok(result));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetMenu(string username)
        {
            var result = new TransferObj <List <ChoiceObj> >();

            try
            {
                var            _unitCode = _service.GetCurrentUnitCode();
                List <AU_MENU> lstMenu   = new List <AU_MENU>();
                if (username.Equals("admin") || username.Equals("hanghanh"))
                {
                    lstMenu = _service.Repository.DbSet.Where(x => x.TrangThai == 10 && x.UnitCode == _unitCode).OrderBy(x => x.Sort).ToList();
                }
                else
                {
                    lstMenu = _service.GetAllForStarting(username, _unitCode);
                }
                result.Data = new List <ChoiceObj>();
                if (lstMenu != null)
                {
                    lstMenu.ForEach(x =>
                    {
                        ChoiceObj obj = new ChoiceObj()
                        {
                            Id     = x.Id,
                            Text   = x.Title,
                            Parent = x.MenuIdCha,
                            Value  = x.MenuId,
                        };
                        result.Data.Add(obj);
                    });
                }
            }
            catch (Exception ex)
            {
                WriteLogs.LogError(ex);
            }
            return(Ok(result));
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> GetAll_PackagingRoot()
        {
            var result = new TransferObj <List <ChoiceObj> >();
            List <ChoiceObj> lstResult    = new List <ChoiceObj>();
            string           rootUnitcode = ConfigurationManager.AppSettings["rootUnitCode"];

            using (OracleConnection connection = new OracleConnection(ConfigurationManager.ConnectionStrings["LTT.Connection"].ConnectionString))
            {
                try
                {
                    connection.Open();
                    if (connection.State == ConnectionState.Open)
                    {
                        OracleCommand cmd = new OracleCommand();
                        cmd.Connection           = connection;
                        cmd.InitialLONGFetchSize = 1000;
                        cmd.CommandText          = "SELECT MABAOBI,TENBAOBI,UNITCODE FROM DM_BAOBI WHERE TRANGTHAI = 10 AND UNITCODE = '" + rootUnitcode + "'";
                        cmd.CommandType          = CommandType.Text;
                        OracleDataReader dataReader = cmd.ExecuteReader();
                        if (dataReader.HasRows)
                        {
                            while (dataReader.Read())
                            {
                                ChoiceObj _DTO     = new ChoiceObj();
                                string    MABAOBI  = dataReader["MABAOBI"] != null ? dataReader["MABAOBI"].ToString() : "";
                                string    TENBAOBI = dataReader["TENBAOBI"] != null ? dataReader["TENBAOBI"].ToString() : "";
                                _DTO.Value       = MABAOBI;
                                _DTO.Text        = MABAOBI + "|" + TENBAOBI;
                                _DTO.Description = TENBAOBI;
                                _DTO.ExtendValue = dataReader["UNITCODE"] != null ? dataReader["UNITCODE"].ToString() : "";
                                lstResult.Add(_DTO);
                            }
                        }
                        if (lstResult.Count > 0)
                        {
                            result.Status = true;
                            result.Data   = lstResult;
                        }
                        else
                        {
                            result.Status  = false;
                            result.Message = "NotFound";
                        }
                    }
                    else
                    {
                        result.Status  = false;
                        result.Message = "NotFound";
                    }
                }
                catch
                {
                    result.Status  = false;
                    result.Message = "NotFound";
                }
                finally
                {
                    connection.Close();
                    connection.Dispose();
                }
            }
            return(Ok(result));
        }
Exemplo n.º 4
0
        public IHttpActionResult GetSelectByMaLoaiRoot(string maloai)
        {
            var              result       = new TransferObj <List <ChoiceObj> >();
            string           rootUnitcode = ConfigurationManager.AppSettings["rootUnitCode"];
            List <ChoiceObj> lstResult    = new List <ChoiceObj>();

            using (OracleConnection connection = new OracleConnection(ConfigurationManager.ConnectionStrings["LTT.Connection"].ConnectionString))
            {
                try
                {
                    connection.Open();
                    if (connection.State == ConnectionState.Open)
                    {
                        OracleCommand cmd = new OracleCommand();
                        cmd.Connection           = connection;
                        cmd.InitialLONGFetchSize = 1000;
                        cmd.CommandText          = "SELECT MALOAIVATTU,MANHOMVTU,TENNHOMVT,UNITCODE FROM DM_NHOMVATTU WHERE TRANGTHAI = 10 AND MALOAIVATTU = '" + maloai + "' AND UNITCODE = '" + rootUnitcode + "'";
                        cmd.CommandType          = CommandType.Text;
                        OracleDataReader dataReader = cmd.ExecuteReader();
                        if (dataReader.HasRows)
                        {
                            while (dataReader.Read())
                            {
                                ChoiceObj _DTO        = new ChoiceObj();
                                string    MALOAIVATTU = dataReader["MALOAIVATTU"] != null ? dataReader["MALOAIVATTU"].ToString() : "";
                                string    MANHOMVTU   = dataReader["MANHOMVTU"] != null ? dataReader["MANHOMVTU"].ToString() : "";
                                string    TENNHOMVT   = dataReader["TENNHOMVT"] != null ? dataReader["TENNHOMVT"].ToString() : "";
                                _DTO.Value       = MANHOMVTU;
                                _DTO.Text        = MANHOMVTU + " | " + TENNHOMVT;
                                _DTO.Description = TENNHOMVT;
                                _DTO.ExtendValue = dataReader["UNITCODE"] != null ? dataReader["UNITCODE"].ToString() : "";
                                _DTO.Parent      = MALOAIVATTU;
                                lstResult.Add(_DTO);
                            }
                        }
                        if (lstResult.Count > 0)
                        {
                            result.Status = true;
                            result.Data   = lstResult;
                        }
                        else
                        {
                            result.Status  = false;
                            result.Message = "NotFound";
                        }
                    }
                    else
                    {
                        result.Status  = false;
                        result.Message = "NotFound";
                    }
                }
                catch
                {
                    result.Status  = false;
                    result.Message = "NotFound";
                }
                finally
                {
                    connection.Close();
                    connection.Dispose();
                }
            }
            return(Ok(result));
        }
Exemplo n.º 5
0
        public IHttpActionResult GetAll_TaxRoot()
        {
            var result = new TransferObj <List <ChoiceObj> >();
            List <ChoiceObj> lstResult    = new List <ChoiceObj>();
            string           rootUnitcode = ConfigurationManager.AppSettings["rootUnitCode"];

            using (OracleConnection connection = new OracleConnection(ConfigurationManager.ConnectionStrings["LTT.Connection"].ConnectionString))
            {
                try
                {
                    connection.Open();
                    if (connection.State == ConnectionState.Open)
                    {
                        OracleCommand cmd = new OracleCommand();
                        cmd.Connection           = connection;
                        cmd.InitialLONGFetchSize = 1000;
                        cmd.CommandText          = "SELECT MALOAITHUE,LOAITHUE,TYGIA,TAIKHOANKT,TRANGTHAI,UNITCODE FROM DM_LOAITHUE WHERE TRANGTHAI = 10 AND UNITCODE = '" + rootUnitcode + "'";
                        cmd.CommandType          = CommandType.Text;
                        OracleDataReader dataReader = cmd.ExecuteReader();
                        if (dataReader.HasRows)
                        {
                            while (dataReader.Read())
                            {
                                int       TRANGTHAI  = 0;
                                decimal   TYGIA      = 0;
                                ChoiceObj _DTO       = new ChoiceObj();
                                string    MALOAITHUE = dataReader["MALOAITHUE"] != null ? dataReader["MALOAITHUE"].ToString() : "";
                                string    LOAITHUE   = dataReader["LOAITHUE"] != null ? dataReader["LOAITHUE"].ToString() : "";
                                int.TryParse(dataReader["TRANGTHAI"] != null ? dataReader["TRANGTHAI"].ToString() : "", out TRANGTHAI);
                                decimal.TryParse(dataReader["TYGIA"] != null ? dataReader["TYGIA"].ToString() : "", out TYGIA);
                                _DTO.Value       = MALOAITHUE;
                                _DTO.Text        = MALOAITHUE + "|" + LOAITHUE;
                                _DTO.Description = LOAITHUE;
                                _DTO.ExtendValue = TYGIA.ToString();
                                lstResult.Add(_DTO);
                            }
                        }
                        if (lstResult.Count > 0)
                        {
                            result.Status = true;
                            result.Data   = lstResult;
                        }
                        else
                        {
                            result.Status  = false;
                            result.Message = "NotFound";
                        }
                    }
                    else
                    {
                        result.Status  = false;
                        result.Message = "NotFound";
                    }
                }
                catch
                {
                    result.Status  = false;
                    result.Message = "NotFound";
                }
                finally
                {
                    connection.Close();
                    connection.Dispose();
                }
            }
            return(Ok(result));
        }