Example #1
0
        public string BuildCodeChildren(string maCuaHang)
        {
            var unitCode = GetCurrentUnitCode();
            var type     = TypeBuildCode.CUAHANG.ToString();
            var result   = "";
            var idRepo   = UnitOfWork.Repository <CAPMA>();
            var config   = idRepo.DbSet.FirstOrDefault(x => x.LOAIMA == type && x.NHOMMA == maCuaHang && x.UNITCODE == unitCode);

            if (config == null)
            {
                config = new CAPMA
                {
                    ID       = Guid.NewGuid().ToString(),
                    LOAIMA   = type,
                    NHOMMA   = maCuaHang,
                    GIATRI   = "0",
                    UNITCODE = unitCode
                };
            }
            var newNumber = config.GenerateNumber();

            config.GIATRI = newNumber;
            result        = string.Format("{0}{1}", maCuaHang, newNumber);
            return(result);
        }
Example #2
0
        public string BuildCode()
        {
            var unitCode = GetCurrentUnitCode();
            var type     = TypeBuildCode.NGUOIDUNG.ToString();
            var result   = "";
            var idRepo   = UnitOfWork.Repository <CAPMA>();
            var config   = idRepo.DbSet.FirstOrDefault(x => x.LOAIMA == type && x.UNITCODE.StartsWith(unitCode));

            if (config == null)
            {
                config = new CAPMA
                {
                    ID       = Guid.NewGuid().ToString(),
                    LOAIMA   = type,
                    NHOMMA   = "NGUOIDUNG",
                    GIATRI   = "0",
                    UNITCODE = unitCode
                };
            }
            var newNumber = config.GenerateNumber();

            config.GIATRI = newNumber;
            result        = string.Format("{0}{1}", config.LOAIMA, newNumber);
            return(result);
        }
Example #3
0
        public string SaveCode()
        {
            var unitCode = GetCurrentUnitCode();
            var type     = TypeBuildCode.CUAHANG.ToString();
            var result   = "";
            var idRepo   = UnitOfWork.Repository <CAPMA>();
            var config   = idRepo.DbSet.FirstOrDefault(x => x.LOAIMA == type && x.UNITCODE == unitCode);

            if (config == null)
            {
                config = new CAPMA
                {
                    ID       = Guid.NewGuid().ToString(),
                    LOAIMA   = type,
                    NHOMMA   = "CUAHANG",
                    GIATRI   = "0",
                    UNITCODE = unitCode
                };
                result        = config.GenerateNumber();
                config.GIATRI = result;
                idRepo.Insert(config);
            }
            else
            {
                result             = config.GenerateNumber();
                config.GIATRI      = result;
                config.ObjectState = ObjectState.Modified;
            }
            result = string.Format("{0}{1}", "0", config.GIATRI);
            return(result);
        }
        public void capmatudong(form_mathang f)
        {
            CAPMA CM = data.database().CAPMAs.SingleOrDefault(a => a.STT == 1);

            i = ((Int32)CM.KISO) + 1;
            f.lb_mamh.Text = CM.KIHIEU + Convert.ToString(i);
        }
Example #5
0
        public string SaveCode(string UnitCodeParam)
        {
            if (string.IsNullOrEmpty(UnitCodeParam))
            {
                return("");
            }
            var type   = TypeBuildCode.LOAIHANG.ToString();
            var result = "";
            var idRepo = UnitOfWork.Repository <CAPMA>();
            var config = idRepo.DbSet.FirstOrDefault(x => x.LOAIMA == type && x.UNITCODE == UnitCodeParam);

            if (config == null)
            {
                config = new CAPMA
                {
                    ID       = Guid.NewGuid().ToString(),
                    LOAIMA   = type,
                    NHOMMA   = "LOAIHANG",
                    GIATRI   = ((char)64).ToString(),
                    UNITCODE = UnitCodeParam
                };
                result        = config.GenerateChar();
                config.GIATRI = result;
                idRepo.Insert(config);
            }
            else
            {
                result             = config.GenerateChar();
                config.GIATRI      = result;
                config.ObjectState = ObjectState.Modified;
            }
            return(result);
        }
Example #6
0
        public void Them()
        {
            KHACHHANG M = new KHACHHANG();

            CAPMA CM   = data.CAPMAs.SingleOrDefault(a => a.STT == 2);
            int   kiso = (Int32)CM.KISO + 1;

            M.MAKH  = CM.KIHIEU + Convert.ToString(kiso.ToString());
            M.TENKH = lb_tenkh.Text;

            if (rdb_nam.Checked == true)
            {
                M.GIOITINH_KH = "Nam";
            }
            if (rdb_nu.Checked == true)
            {
                M.GIOITINH_KH = "Nữ";
            }
            M.DIENTHOAI_KH = lb_sdt.Text;
            M.DIACHI_KH    = txt_diachi.Text;;

            //cap nhat du lieu bang mat hang
            data.KHACHHANGs.InsertOnSubmit(M);
            data.SubmitChanges();

            //cap nhat lại dữ liểu bảng cấp mã
            CM.KISO = kiso;
            data.SubmitChanges();
        }
        //ham them
        public void them(form_mathang f, string tenmh, string loai, string noisx)
        {
            MATHANG M  = new MATHANG();
            CAPMA   CM = data.database().CAPMAs.SingleOrDefault(a => a.STT == 1);

            M.MAMH  = f.lb_mamh.Text;
            M.TENMH = tenmh;

            if (loai == "Tủ")
            {
                M.MALOAI = "LH1";
            }
            if (loai == "Giường")
            {
                M.MALOAI = "LH2";
            }
            if (loai == "Bàn")
            {
                M.MALOAI = "LH3";
            }
            if (loai == "Ghế")
            {
                M.MALOAI = "LH4";
            }
            if (f.rdb_cai.Checked == true)
            {
                M.DVT = "Cái";
            }
            if (f.rdb_m2.Checked == true)
            {
                M.DVT = "m2";
            }
            M.NOISX = noisx;

            M.GIABAN    = 0;
            M.GIAMUA    = 0;
            M.KHUYENMAI = 0;
            M.SLTON     = 0;

            //cap nhat du lieu bang mat hang
            data.database().MATHANGs.InsertOnSubmit(M);
            data.database().SubmitChanges();

            //cap nhat lại dữ liểu bảng cấp mã
            CM.KISO = i + 1;
            data.database().SubmitChanges();

            loaddulieu(f);
        }
        public void capshd(string tenkh, string sdth)
        {
            CAPMA tam = data.database().CAPMAs.SingleOrDefault(a => a.STT == 7);

            sohd = tam.KIHIEU + Convert.ToString(tam.KISO + 1);
            HOADON A = new HOADON();

            A.SOHD       = sohd;
            A.NGAYLAP_HD = DateTime.Now;
            //  A.MANV = BATDAU.manv;
            A.TONGTG       = 0;
            A.TT_THANHTOAN = "";
            KHACHHANG K = data.database().KHACHHANGs.SingleOrDefault(a => a.TENKH == tenkh && a.DIENTHOAI_KH == sdth);

            if (K != null)
            {
                A.MAKH = K.MAKH;
            }
            data.database().HOADONs.InsertOnSubmit(A);
            data.database().SubmitChanges();
            tam.KISO = tam.KISO + 1;
            data.database().SubmitChanges();
        }