示例#1
0
        public string BuildCode()
        {
            var type       = TypeMasterData.NCC.ToString();
            var result     = "";
            var idRepo     = UnitOfWork.Repository <MdIdBuilder>();
            var maDonViCha = GetParentUnitCode();
            var config     = idRepo.DbSet.Where(x => x.Type == type && x.UnitCode == maDonViCha).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id       = Guid.NewGuid().ToString(),
                    Type     = type,
                    Code     = type,
                    Current  = "0000",
                    UnitCode = maDonViCha,
                };
            }
            var soMa = config.GenerateNumber();

            config.Current = soMa;
            result         = string.Format("{0}", soMa);

            return(result);
        }
示例#2
0
        public string SaveCode()
        {
            var type   = TypeMasterData.NCC.ToString();
            var result = "";

            var idRepo     = UnitOfWork.Repository <MdIdBuilder>();
            var maDonViCha = GetParentUnitCode();
            var config     = idRepo.DbSet.Where(x => x.Type == type && x.UnitCode == maDonViCha).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id       = Guid.NewGuid().ToString(),
                    Type     = type,
                    Code     = type,
                    Current  = "0000",
                    UnitCode = maDonViCha,
                };
                result         = config.GenerateNumber();
                config.Current = result;
                idRepo.Insert(config);
            }
            else
            {
                result             = config.GenerateNumber();
                config.Current     = result;
                config.ObjectState = ObjectState.Modified;
            }
            result = string.Format("{0}", config.Current);
            return(result);
        }
        public string BuildCode(string code)
        {
            var type       = TypeMasterData.VATTU.ToString();
            var maDonViCha = GetParentUnitCode();
            var result     = "";
            var loaiVatTu  = UnitOfWork.Repository <MdMerchandiseType>().DbSet.First(x => x.MaLoaiVatTu == code && x.UnitCode.StartsWith(maDonViCha));

            if (loaiVatTu != null)
            {
                var idRepo = UnitOfWork.Repository <MdIdBuilder>();
                var config = idRepo.DbSet.Where(x => x.Type == type && x.Code == loaiVatTu.MaLoaiVatTu && x.UnitCode == maDonViCha).FirstOrDefault();
                if (config == null)
                {
                    config = new MdIdBuilder
                    {
                        Id       = Guid.NewGuid().ToString(),
                        Type     = type,
                        Code     = loaiVatTu.MaLoaiVatTu,
                        Current  = "000000",
                        UnitCode = maDonViCha,
                    };
                }
                var soMa = config.GenerateNumber();
                config.Current = soMa;
                result         = string.Format("{0}{1}", config.Code, soMa);
            }
            return(result);
        }
示例#4
0
        public string SaveCode(TypeVoucher type = TypeVoucher.XBANLE)
        {
            var result  = "";
            var strType = type.ToString();
            var idRepo  = UnitOfWork.Repository <MdIdBuilder>();
            var config  = idRepo.DbSet.Where(x => x.Type == strType).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id      = Guid.NewGuid().ToString(),
                    Type    = strType,
                    Code    = strType,
                    Current = "0",
                };
                config.Current = config.GenerateNumber();
                idRepo.Insert(config);
            }
            else
            {
                config.Current     = config.GenerateNumber();
                config.ObjectState = ObjectState.Modified;
            }
            result = string.Format("{0}{1}", config.Code, config.Current);
            return(result);
        }
        public string SaveCodeChild(string code)
        {
            var type   = TypeMasterData.VATTU.ToString();
            var result = "";
            var vatTu  = UnitOfWork.Repository <MdMerchandise>().DbSet.First(x => x.MaVatTu == code);

            if (vatTu != null)
            {
                var idRepo = UnitOfWork.Repository <MdIdBuilder>();
                var config = idRepo.DbSet.Where(x => x.Type == type && x.Code == vatTu.MaVatTu).FirstOrDefault();
                if (config == null)
                {
                    config = new MdIdBuilder
                    {
                        Id      = Guid.NewGuid().ToString(),
                        Type    = type,
                        Code    = vatTu.MaVatTu,
                        Current = "00",
                    };

                    result         = config.GenerateNumber();
                    config.Current = result;
                    idRepo.Insert(config);
                }
                else
                {
                    result             = config.GenerateNumber();
                    config.Current     = result;
                    config.ObjectState = ObjectState.Modified;
                }

                result = string.Format("{0}{1}", config.Code, result);
            }
            return(result);
        }
示例#6
0
        public string SaveCode()
        {
            var maDonViCha = GetParentUnitCode();
            var type       = TypeMasterData.LOAIHANG.ToString();
            var result     = "";
            var idRepo     = UnitOfWork.Repository <MdIdBuilder>();
            var strType    = type.ToString();
            var config     = idRepo.DbSet.Where(x => x.Type == strType && x.UnitCode == maDonViCha).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id       = Guid.NewGuid().ToString(),
                    Type     = strType,
                    Current  = ((char)64).ToString(),
                    UnitCode = maDonViCha
                };
                result         = config.GenerateChar();
                config.Current = result;
                idRepo.Insert(config);
            }
            else
            {
                result             = config.GenerateChar();
                config.Current     = result;
                config.ObjectState = ObjectState.Modified;
            }
            ;
            return(result);
        }
示例#7
0
        public string SaveCodeByParent(string unitCode)
        {
            var type   = TypeMasterData.NV.ToString();
            var result = "";
            var idRepo = UnitOfWork.Repository <MdIdBuilder>();
            var config = idRepo.DbSet.Where(x => x.Type == type && x.UnitCode == unitCode).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id       = Guid.NewGuid().ToString(),
                    Type     = type,
                    Code     = type,
                    UnitCode = unitCode,
                    Current  = "0",
                };
                result         = config.GenerateNumber();
                config.Current = result;
                idRepo.Insert(config);
            }
            else
            {
                result             = config.GenerateNumber();
                config.Current     = result;
                config.ObjectState = ObjectState.Modified;
            }
            result = unitCode + "-" + config.Code + config.Current;
            return(result);
        }
示例#8
0
        public string BuildCodeByParent(string unitCode)
        {
            var type   = TypeMasterData.NV.ToString();
            var result = "";
            var idRepo = UnitOfWork.Repository <MdIdBuilder>();
            var config = idRepo.DbSet.Where(x => x.Type == type && x.UnitCode == unitCode).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id       = Guid.NewGuid().ToString(),
                    Type     = type,
                    Code     = type,
                    UnitCode = unitCode,
                    Current  = "0",
                };
            }
            var soMa = config.GenerateNumber();

            config.Current = soMa;
            result         = unitCode + "-" + config.Code + soMa;

            return(result);
        }
示例#9
0
        public string BuildCode(string type = "DHNCC")
        {
            var result = "";
            var idRepo = UnitOfWork.Repository <MdIdBuilder>();
            var config = idRepo.DbSet.Where(x => x.Type == type).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id      = Guid.NewGuid().ToString(),
                    Type    = type.ToString(),
                    Code    = type.ToString(),
                    Current = "0",
                };
            }
            var soPhieu = config.GenerateNumber();

            config.Current = soPhieu;
            result         = string.Format("{0}{1}", config.Code, soPhieu);
            return(result);
        }
示例#10
0
        public string BuildCode(TypeVoucher type = TypeVoucher.XBANLE)
        {
            var result  = "";
            var idRepo  = UnitOfWork.Repository <MdIdBuilder>();
            var strType = type.ToString();
            var config  = idRepo.DbSet.Where(x => x.Type == strType).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id      = Guid.NewGuid().ToString(),
                    Type    = type.ToString(),
                    Code    = type.ToString(),
                    Current = "0",
                };
            }
            var maChungTuGenerate = config.GenerateNumber();

            config.Current = maChungTuGenerate;
            result         = string.Format("{0}{1}", config.Code, maChungTuGenerate);
            return(result);
        }
示例#11
0
        public string BuildCode_BD(string BD, string _unicode, bool _isSave)
        {
            var  result   = "";
            bool isInsert = false;
            var  idRepo   = UnitOfWork.Repository <MdIdBuilder>();
            var  config   = idRepo.DbSet.Where(x => x.Type == BD && x.UnitCode.StartsWith(_unicode)).FirstOrDefault();

            if (config == null)
            {
                isInsert = true;
                config   = new MdIdBuilder
                {
                    Id       = Guid.NewGuid().ToString(),
                    Type     = BD,
                    Code     = BD,
                    UnitCode = _unicode,
                    Current  = "0",
                };
            }
            var maBaoDateGenerate = config.GenerateNumber();

            config.Current = maBaoDateGenerate;
            result         = string.Format("{0}{1}", config.Code, maBaoDateGenerate);
            if (_isSave)
            {
                if (isInsert)
                {
                    idRepo.Insert(config);
                }
                else
                {
                    config.ObjectState = ObjectState.Modified;
                    UnitOfWork.Save();
                }
            }
            return(result);
        }
        public string BuildCodeCanDienTu()
        {
            var type   = TypeMasterData.CANDIENTU.ToString();
            var result = "";

            var idRepo = UnitOfWork.Repository <MdIdBuilder>();
            var config = idRepo.DbSet.Where(x => x.Type == type).FirstOrDefault();

            if (config == null)
            {
                config = new MdIdBuilder
                {
                    Id      = Guid.NewGuid().ToString(),
                    Type    = type,
                    Code    = type,
                    Current = "00000",
                };
            }
            var soMa = config.GenerateNumber();

            config.Current = soMa;
            result         = string.Format("{0}", soMa);
            return(result);
        }
示例#13
0
        public string SaveCodeRoot()
        {
            var    result       = "";
            var    type         = TypeMasterData.KH.ToString();
            string rootUnitcode = ConfigurationManager.AppSettings["rootUnitCode"];
            string maDonViCha   = GetParentUnitCode();

            using (OracleConnection connection = new OracleConnection(ConfigurationManager.ConnectionStrings["LTT.Connection"].ConnectionString))
            {
                try
                {
                    connection.Open();
                    if (connection.State == ConnectionState.Open)
                    {
                        MdIdBuilder   config = new MdIdBuilder();
                        OracleCommand cmd    = new OracleCommand();
                        cmd.Connection           = connection;
                        cmd.InitialLONGFetchSize = 1000;
                        cmd.CommandText          = "SELECT ID,TYPE,CODE,\"CURRENT\",UNITCODE FROM MD_ID_BUILDER WHERE TYPE = '" + type + "' AND CODE = '" + type + "' AND UNITCODE = '" + maDonViCha + "' AND ROWNUM = 1";
                        cmd.CommandType          = CommandType.Text;
                        OracleDataReader dataReader = cmd.ExecuteReader();
                        if (dataReader.HasRows)
                        {
                            while (dataReader.Read())
                            {
                                config = new MdIdBuilder
                                {
                                    Id       = dataReader["ID"].ToString(),
                                    Type     = type,
                                    Code     = type,
                                    Current  = dataReader["CURRENT"].ToString(),
                                    UnitCode = maDonViCha
                                };
                                result          = config.GenerateNumber();
                                config.Current  = result;
                                cmd.CommandText = "UPDATE MD_ID_BUILDER SET \"CURRENT\" = '" + result + "' WHERE TYPE = '" + type + "' AND CODE = '" + type + "' AND UNITCODE = '" + maDonViCha + "' ";
                                cmd.CommandType = CommandType.Text;
                                int countUpdate = cmd.ExecuteNonQuery();
                            }
                        }
                        else
                        {
                            config = new MdIdBuilder
                            {
                                Id       = Guid.NewGuid().ToString(),
                                Type     = type,
                                Code     = type,
                                Current  = "0",
                                UnitCode = maDonViCha
                            };
                            result          = config.GenerateNumber();
                            config.Current  = result;
                            cmd.CommandText = "INSERT INTO MD_ID_BUILDER(ID,TYPE,CODE,CURRENT,UNITCODE) VALUES ('" + config.Id + "','" + config.Type + "','" + config.Code + "','" + config.Current + "','" + config.UnitCode + "')";
                            cmd.CommandType = CommandType.Text;
                            int count = cmd.ExecuteNonQuery();
                        }
                        result = string.Format("{0}{1}", config.Code, result);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    connection.Close();
                    connection.Dispose();
                }
            }
            return(result);
        }