Exemplo n.º 1
0
 public IHttpActionResult GetTableNameByDate(ParameterInventory param)
 {
     if (param.FromDate != null || param.ToDate != null)
     {
         var      result = new TransferObj();
         DateTime day    = new DateTime(param.FromDate.Year, param.FromDate.Month, param.FromDate.Day, 0, 0, 0);
         var      data   = _service.Repository.DbSet.FirstOrDefault(x => x.FromDate == day);
         if (data != null)
         {
             string tableName = ProcedureCollection.GetTableName(data.Year, data.Period);
             result.Data    = tableName;
             result.Status  = true;
             result.Message = "Ok";
             return(Ok(result));
         }
         else
         {
             result.Message = "Chưa khởi tạo kỳ kế toán";
             return(NotFound());
         }
     }
     else
     {
         return(NotFound());
     }
 }
Exemplo n.º 2
0
        public StateProcessApproval Approval(string id)
        {
            StateProcessApproval result;
            var unitCode = GetCurrentUnitCode();
            var periods  = CurrentSetting.GetKhoaSo(unitCode);

            if (periods != null)
            {
                var tableName = ProcedureCollection.GetTableName(periods.Year, periods.Period);
                if (ProcedureCollection.DecreaseVoucher(tableName, periods.Year, periods.Period, id))
                {
                    result = StateProcessApproval.Success;
                }
                else
                {
                    result = StateProcessApproval.Failed;
                }
            }
            else
            {
                result = StateProcessApproval.NoPeriod;
            }

            return(result);
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> FilterCustomerData(string strKey)
        {
            var result   = new TransferObj();
            var unitCode = _serviceCustomer.GetCurrentUnitCode();

            try
            {
                var serviceProcedure = new ProcedureService <MdCustomerVm.CustomerDto>();
                var data             = ProcedureCollection.QueryCustomer(unitCode, strKey);
                if (data.Count > 0)
                {
                    result.Data    = data;
                    result.Status  = true;
                    result.Message = "Truy vấn thành công";
                }
                else
                {
                    result.Data    = null;
                    result.Status  = false;
                    result.Message = "Không tìm thấy";
                }
            }
            catch (Exception ex)
            {
                result.Data    = null;
                result.Status  = false;
                result.Message = "Không tìm thấy";
            }
            return(Ok(result));
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> BindingDataHangHoa(string strKey)
        {
            var result   = new TransferObj();
            var unitCode = _serviceRetails.GetCurrentUnitCode();

            try
            {
                var serviceProcedure = new ProcedureService <MdMerchandiseVm.FilterData>();
                var data             = ProcedureCollection.QueryFilterMerchandise(unitCode, strKey);
                if (data.Count > 0)
                {
                    result.Data    = data;
                    result.Status  = true;
                    result.Message = "Truy vấn thành công";
                }
                else
                {
                    result.Data    = null;
                    result.Status  = false;
                    result.Message = "Không tìm thấy";
                }
            }
            catch (Exception ex)
            {
                result.Data    = null;
                result.Status  = false;
                result.Message = "Không tìm thấy";
            }
            return(Ok(result));
        }
Exemplo n.º 5
0
        public async Task <IHttpActionResult> GetKhuyenMaiHangTangHang()
        {
            string unitCode = _serviceCustomer.GetCurrentUnitCode();
            var    result   = new TransferObj <List <NvKhuyenMaiBuy1Get1Vm.ListHangTangHang> >();

            try
            {
                var returnData = ProcedureCollection.GetKhuyenMaiHangTangHang(unitCode);
                if (returnData != null && returnData.Count > 0)
                {
                    result.Data   = returnData;
                    result.Status = true;
                }
                else
                {
                    result.Data   = null;
                    result.Status = false;
                }
            }
            catch (Exception ex)
            {
                result.Data   = null;
                result.Status = false;
            }
            return(Ok(result));
        }
Exemplo n.º 6
0
        public void IgnoresExistingProcedures()
        {
            var bydigest = new Dictionary <String, ProcedureDefinition>
            {
                { "digest1", new ProcedureDefinition()
                  {
                      Body = "digestBody1"
                  } },
                { "digest2", new ProcedureDefinition()
                  {
                      Body = "digestBody2"
                  } }
            };
            var byalias = new Dictionary <String, ProcedureDefinition>();

            var procedures     = new ProcedureCollection(byalias, bydigest);
            var initializer    = new ProcedureInitializer(procedures, NoLogger.Instance);
            var writtingStream = new MemoryStream();
            var reader         = new DummySocketReader("*2\r\n:1\r\n:1\r\n");
            var writer         = new DummySocketWriter(writtingStream);

            initializer.Initialize(reader, writer);
            writer.Flush();
            writtingStream.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual("*4\r\n$6\r\nSCRIPT\r\n$6\r\nexists\r\n$7\r\ndigest1\r\n$7\r\ndigest2\r\n", new StreamReader(writtingStream).ReadToEnd());
        }
Exemplo n.º 7
0
    IEnumerator getProcedureData()
    {
        using (WWW www = new WWW(proceduresUrl))
        {
            yield return(www);

            DataController.pdata = JsonUtility.FromJson <ProcedureCollection>("{\"procedures\":" + www.text + "}");
        }
    }
Exemplo n.º 8
0
        public bool ModifieldCodeMerchandise(string maVatTu, string id, string maNhomVatTu)
        {
            bool result = false;
            var  data   = ProcedureCollection.UpdateCodeGroup(id, maVatTu, maNhomVatTu);

            if (data == true)
            {
                result = true;
            }
            return(result);
        }
Exemplo n.º 9
0
 public void Init()
 {
     _procedures = ProcedureCollection.Empty;
     _multiplex  = new Mock <ICommandConnection>();
     _multiplex.Setup(x => x.ConnectAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult <Object>(null));
     _pool = new Mock <IConnectionProvider <ICommandConnection> >();
     _pool.Setup(x => x.ConnectAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult <Object>(null));
     _subscriber = new Mock <IConnectionProvider <ISubscriptionConnection> >();
     _subscriber.Setup(x => x.ConnectAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult <Object>(null));
     _channel = new RedisChannel(new ExecutionPlanner(_procedures), _procedures, _multiplex.Object, _subscriber.Object, _pool.Object);
 }
Exemplo n.º 10
0
        public async Task <IHttpActionResult> GetDataPackageMerchandise(string maBoHang)
        {
            MdMerchandiseVm.DataBoHang result = null;
            //Tạm thời khóa mã đơn vị
            var unitCode = _serviceUser.GetCurrentUnitCode();
            var maKho    = _serviceUser.GetCurrentUnitCode() + "-K2";
            var service  = new ProcedureService <MdMerchandiseVm.DtoAndPromotion>();

            if (maBoHang.Substring(0, 2).Equals("BH"))
            {
                try
                {
                    var data = ProcedureCollection.GetDataBoHang(new BTS.API.ENTITY.ERPContext(), maBoHang, unitCode);
                    if (data != null)
                    {
                        foreach (var i in data.ListMaHang)
                        {
                            string codeMerchandise = i.MaVatTu;
                            //check tồn mã hàng này
                            var xntItem = ProcedureCollection.GetCostOfGoodsSoldByMerchandise(unitCode, maKho, codeMerchandise);
                            if (xntItem != null)
                            {
                                i.TonCuoiKySl       = xntItem.ClosingQuantity == 0 ? 0 : xntItem.ClosingQuantity;
                                i.LogKhuyenMaiError = 1;
                                i.IsBanAm           = false;
                                i.Status            = true;
                                i.Message           = "Bán mã bó hàng";
                                i.NoiDungKhuyenMai  = "Khuyến mại bó hàng";

                                if (i.TonCuoiKySl <= 0)
                                {
                                    i.LogKhuyenMaiError = 1;
                                    i.IsBanAm           = true;
                                    i.Status            = true;
                                    i.Message           = "Bán mã bó hàng";
                                    i.NoiDungKhuyenMai  = "Khuyến mại bó hàng";
                                }
                            }
                            //end check tồn
                        }
                    }
                    else
                    {
                    }
                    result = data;
                }
                catch (Exception ex)
                {
                    return(NotFound());
                }
            }
            return(Ok(result));
        }
Exemplo n.º 11
0
        public async Task <IHttpActionResult> GetKhuyenMaiCombo()
        {
            string unitCode = _serviceCustomer.GetCurrentUnitCode();
            var    data     = new NvKhuyenMaiComboVm.ListCombo();
            var    result   = new TransferObj <NvKhuyenMaiComboVm.ListCombo>();

            try
            {
                var returnData = ProcedureCollection.GetKhuyenMaiCombo(unitCode);
                if (returnData != null && returnData.Count > 0)
                {
                    foreach (var record in returnData)
                    {
                        data.ListComboLeft.Add(record);
                        data.ListComboRight.Add(record);
                    }
                    var groupByComboLeft = data.ListComboLeft.GroupBy(x => new { x.MaVatTuLeft, x.MaChuongTrinh, x.GiaTriKhuyenMai, x.SoLuongKhuyenMai }).Select(group => new NvKhuyenMaiComboVm.ListCombo()
                    {
                        MaVatTuLeft      = group.Key.MaVatTuLeft,
                        MaChuongTrinh    = group.Key.MaChuongTrinh,
                        GiaTriKhuyenMai  = group.Key.GiaTriKhuyenMai,
                        SoLuongKhuyenMai = group.Key.SoLuongKhuyenMai,
                    }).ToList();
                    var groupByComboRight = data.ListComboRight.GroupBy(x => new { x.MaVatTuRight, x.MaChuongTrinh, x.GiaTriKhuyenMai, x.SoLuongKhuyenMai }).Select(group => new NvKhuyenMaiComboVm.ListCombo()
                    {
                        MaVatTuRight     = group.Key.MaVatTuRight,
                        MaChuongTrinh    = group.Key.MaChuongTrinh,
                        GiaTriKhuyenMai  = group.Key.GiaTriKhuyenMai,
                        SoLuongKhuyenMai = group.Key.SoLuongKhuyenMai,
                    }).ToList();
                    if (groupByComboLeft.Count > 0 || groupByComboRight.Count > 0)
                    {
                        result.Data = new NvKhuyenMaiComboVm.ListCombo();
                        result.Data.ListComboLeft  = groupByComboLeft;
                        result.Data.ListComboRight = groupByComboRight;
                    }
                    result.Status = true;
                }
                else
                {
                    result.Data   = null;
                    result.Status = false;
                }
            }
            catch (Exception ex)
            {
                result.Data   = null;
                result.Status = false;
            }
            return(Ok(result));
        }
Exemplo n.º 12
0
        public void IgnoresNoInitialization()
        {
            var procedures     = new ProcedureCollection();
            var initializer    = new ProcedureInitializer(procedures, NoLogger.Instance);
            var writtingStream = new MemoryStream();
            var reader         = new DummySocketReader(null);
            var writer         = new DummySocketWriter(writtingStream);

            initializer.Initialize(reader, writer);
            writer.Flush();
            writtingStream.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(0, writtingStream.Position);
        }
Exemplo n.º 13
0
        public async Task <IHttpActionResult> GetMerchandiseByCodeKK(string MaHang)
        {
            var    unitCode = _service.GetCurrentUnitCode();
            string MaKho    = unitCode + "-K2";

            NvKiemKeVm.Dto lst = new NvKiemKeVm.Dto();
            try
            {
                String[] strArray  = new String[] { MaHang };
                string   paraVatTu = String.Join(",", strArray);
                lst.DataDetails = ProcedureCollection.GetInventoryForActionInventoryByOne(unitCode, MaKho, paraVatTu);
            }
            catch (Exception ex)
            {
                return(NotFound());
            }
            return(Ok(lst));
        }
        public async Task <IHttpActionResult> GetForNvByCode(string code)
        {
            MdMerchandiseVm.Dto result = null;
            var unitCode = _service.GetCurrentUnitCode();
            //var instance = _service.Repository.DbSet.FirstOrDefault(x => x.MaVatTu.ToUpper() == code.ToUpper());//&& x.UnitCode == unitCode);
            var service = new ProcedureService <MdMerchandiseTypeVm.Dto>();
            var data    = ProcedureCollection.GetMerchandiseType(new BTS.API.ENTITY.ERPContext(), code, unitCode);

            if (data != null && data.Count() >= 1)
            {
                var items = data.ToList();


                return(Ok(items[0]));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 15
0
        public string GetKyKeToan(DateTime ngayChungTu)
        {
            DateTime beginDay = new DateTime(ngayChungTu.Year, ngayChungTu.Month, ngayChungTu.Day, 0, 0, 0);
            DateTime endDay   = new DateTime(ngayChungTu.Year, ngayChungTu.Month, ngayChungTu.Day, 23, 59, 59);

            var kyKeToan = Repository.DbSet.FirstOrDefault(x => x.FromDate >= beginDay && x.FromDate <= endDay);

            if (kyKeToan != null)
            {
                return(ProcedureCollection.GetTableName(kyKeToan.Year, kyKeToan.Period));
            }
            else
            {
                var now = DateTime.Now;
                beginDay = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
                endDay   = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);
                kyKeToan = Repository.DbSet.FirstOrDefault(x => x.FromDate >= beginDay && x.FromDate <= endDay);
                return(ProcedureCollection.GetTableName(kyKeToan.Year, kyKeToan.Period));
            }
        }
Exemplo n.º 16
0
        public async Task <IHttpActionResult> GetExternalCode(ParameterKiemKe para)
        {
            string   unitCode   = _service.GetCurrentUnitCode();
            MdPeriod curentDate = CurrentSetting.GetKhoaSo(unitCode);

            if (para.WareHouseCodes == null)
            {
                para.WareHouseCodes = unitCode + "-K2";
            }
            string tableName = curentDate.GetTableName();
            List <NvKiemKeVm.ExternalCodeInInventory> result = new List <NvKiemKeVm.ExternalCodeInInventory>();

            result = ProcedureCollection.GetExternalCodeInventory(unitCode, tableName, para);
            if (result != null)
            {
                return(Ok(result));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 17
0
        public List <InventoryDetailItem> CreateReportXNTNewTongHop(ParameterInventory pi)
        {
            List <InventoryDetailItem> data = new List <InventoryDetailItem>();
            DateTime beginDay, endDay;
            string   ky = string.Empty;

            beginDay = new DateTime(pi.FromDate.Year, pi.FromDate.Month, pi.FromDate.Day, 0, 0, 0);
            endDay   = new DateTime(pi.ToDate.Year, pi.ToDate.Month, pi.ToDate.Day, 23, 59, 59);

            var period = UnitOfWork.Repository <MdPeriod>().DbSet.FirstOrDefault(x => x.FromDate >= beginDay && x.FromDate <= endDay);

            if (period != null)
            {
                ky = ProcedureCollection.GetTableName(period.Year, period.Period);
            }
            switch (pi.GroupBy)
            {
            case TypeGroupInventory.TYPE:
                data = ProcedureCollection.ReportXNTNew_TongHop(pi.FromDate, pi.ToDate, pi.UnitCode, pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, InventoryGroupBy.MALOAIVATTU.ToString(), pi.NhaCungCapCodes);
                break;

            case TypeGroupInventory.GROUP:
                data = ProcedureCollection.ReportXNTNew_TongHop(pi.FromDate, pi.ToDate, pi.UnitCode, pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, InventoryGroupBy.MANHOMVATTU.ToString(), pi.NhaCungCapCodes);
                break;

            case TypeGroupInventory.NHACUNGCAP:
                data = ProcedureCollection.ReportXNTNew_TongHop(pi.FromDate, pi.ToDate, pi.UnitCode, pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, InventoryGroupBy.MANHACUNGCAP.ToString(), pi.NhaCungCapCodes);
                break;

            case TypeGroupInventory.WAREHOUSE:
                data = ProcedureCollection.ReportXNTNew_TongHop(pi.FromDate, pi.ToDate, pi.UnitCode, pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, InventoryGroupBy.MAKHO.ToString(), pi.NhaCungCapCodes);
                break;

            default:
                data = ProcedureCollection.ReportXNTNew_TongHop(pi.FromDate, pi.ToDate, pi.UnitCode, pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, InventoryGroupBy.MAVATTU.ToString(), pi.NhaCungCapCodes);
                break;
            }
            return(data);
        }
Exemplo n.º 18
0
 public IHttpActionResult GetSoLuongTonByDate(ParameterInventory param)
 {
     if (param.FromDate != null || param.ToDate != null)
     {
         var      result = new TransferObj();
         DateTime day    = new DateTime(param.FromDate.Year, param.FromDate.Month, param.FromDate.Day, 0, 0, 0);
         var      data   = _service.Repository.DbSet.FirstOrDefault(x => x.FromDate == day);
         if (data != null)
         {
             MdPeriodVm.ResponseData dataResult = new MdPeriodVm.ResponseData();
             string tableName     = ProcedureCollection.GetTableName(data.Year, data.Period);
             var    getTonKhoXuat = string.Format("SELECT TONCUOIKYSL FROM {0} where MAVATTU = '{1}' and MAKHO = '{2}'", tableName, param.MerchandiseCodes.ToUpper(), param.WareHouseCodes);
             var    getTonKhoNhap = string.Format("SELECT TONCUOIKYSL FROM {0} where MAVATTU = '{1}' and MAKHO = '{2}'", tableName, param.MerchandiseCodes.ToUpper(), param.WareHouseRecieveCode);
             using (var ctx = new ERPContext())
             {
                 decimal soLuongTonKhoXuat = ctx.Database.SqlQuery <decimal> (getTonKhoXuat).SingleOrDefault();
                 decimal soLuongTonKhoNhap = ctx.Database.SqlQuery <decimal>(getTonKhoNhap).SingleOrDefault();
                 dataResult.SoLuongTonKhoNhap = soLuongTonKhoNhap;
                 dataResult.SoLuongTonKhoXuat = soLuongTonKhoXuat;
                 result.Data = dataResult;
             }
             result.Status  = true;
             result.Message = "Ok";
             return(Ok(result));
         }
         else
         {
             result.Message = "Chưa khởi tạo kỳ kế toán";
             return(NotFound());
         }
     }
     else
     {
         return(NotFound());
     }
 }
Exemplo n.º 19
0
        public async Task <IHttpActionResult> ReceiveDataKiemKe(string MaKho)
        {
            string UNITCODE_GLOBAL = "";

            NvKiemKeVm.Dto returnList = new NvKiemKeVm.Dto();
            if (!string.IsNullOrEmpty(MaKho))
            {
                UNITCODE_GLOBAL = MaKho.Substring(0, MaKho.LastIndexOf('-'));
                NvKiemKeVm.Dto lst     = new NvKiemKeVm.Dto();
                List <string>  vatTu   = new List <string>();
                string         path    = HttpContext.Current.Server.MapPath("/Upload/KiemKe/");
                HttpRequest    request = HttpContext.Current.Request;
                if (request.Files.Count > 0)
                {
                    try
                    {
                        HttpPostedFile file = request.Files[0];
                        file.SaveAs(path + file.FileName);
                        //kiem tra ton tai file
                        if (File.Exists(path + file.FileName))
                        {
                            if (file.FileName.Contains(".txt"))
                            {
                                //doc du lieu tu file text
                                string[] lines = File.ReadAllLines(path + file.FileName);
                                foreach (string line in lines)
                                {
                                    string[] data        = line.Split(',');
                                    string   MaVatTu     = data[0].ToString();
                                    string   SoTonKiemKe = data[1].ToString();
                                    vatTu.Add(MaVatTu);
                                }
                                string[] arrayVatTu = vatTu.ToArray();
                                string   paraVatTu  = String.Join(",", arrayVatTu);
                                lst.DataDetails = ProcedureCollection.GetInventoryForActionInventoryByOne(UNITCODE_GLOBAL, MaKho, paraVatTu);
                                foreach (var value in lst.DataDetails)
                                {
                                    foreach (string line in lines)
                                    {
                                        string[] data = line.Split(',');
                                        if (data[0].ToString() == value.MaVatTu)
                                        {
                                            decimal SoLuongKiemKe = 0;
                                            decimal.TryParse(data[1].ToString(), out SoLuongKiemKe);
                                            value.SoLuongKiemKe = SoLuongKiemKe;
                                            returnList.DataDetails.Add(value);
                                        }
                                    }
                                }
                                returnList.KhoKiemKe  = MaKho;
                                returnList.NgayKiemKe = DateTime.Now.Date;
                                returnList.NgayIn     = DateTime.Now.Date;
                                int    number = 0;
                                string maKe   = "";
                                if (lst.DataDetails.Count > 10)
                                {
                                    for (int i = 0; i < 10; i++)
                                    {
                                        if (lst.DataDetails[i].KeKiemKe == lst.DataDetails[i + 1].KeKiemKe)
                                        {
                                            number++;
                                            maKe = lst.DataDetails[i].KeKiemKe;
                                        }
                                    }
                                }
                                if (number > 5)
                                {
                                    returnList.KeKiemKe = maKe;
                                }
                                else
                                {
                                    returnList.KeKiemKe = lst.DataDetails[0].KeKiemKe;
                                }
                                returnList.MaPhieuKiemKe = _serviceKK.BuildCode();
                            }
                        }
                        else
                        {
                            return(NotFound());
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteLogs.LogError(ex);
                        return(InternalServerError());
                    }
                }
                //lấy những mã không kiểm kê nhưng nằm trong kệ
                string maKeHangHoa = returnList.KeKiemKe;
                var    hangTrongKe = ProcedureCollection.LayThongTinHangThuocKe(UNITCODE_GLOBAL, returnList.KhoKiemKe, maKeHangHoa);
                try
                {
                    if (hangTrongKe != null && hangTrongKe.Count > 0)
                    {
                        for (int i = 0; i < hangTrongKe.Count; i++)
                        {
                            var data = returnList.DataDetails.Find(x => x.MaVatTu == hangTrongKe[i].MaVatTu);
                            if (data == null)
                            {
                                hangTrongKe[i].SoLuongKiemKe = 0;
                                returnList.DataDetails.Add(hangTrongKe[i]);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLogs.LogError(ex);
                }
            }
            else
            {
                return(NotFound());
            }
            return(Ok(returnList));
        }
Exemplo n.º 20
0
        public List <NvKiemKeVm.ObjectReport> ReportKiemKe(ParameterKiemKe pi)
        {
            List <BTS.API.SERVICE.NV.NvKiemKeVm.ObjectReport> data = new List <BTS.API.SERVICE.NV.NvKiemKeVm.ObjectReport>();
            var titleCotName = "";
            var dieuKienLoc  = "";

            switch (pi.ReportType)
            {
            case TypeReportKiemKe.BAOCAOTHUA:
                dieuKienLoc   = "AND NVL(ct.SOLUONGCHENHLECH,0) < 0";
                titleCotName += "(Báo cáo thừa) ";
                break;

            case TypeReportKiemKe.BAOCAOTHIEU:
                dieuKienLoc   = "AND NVL(ct.SOLUONGCHENHLECH,0) > 0";
                titleCotName += "(Báo cáo thiếu) ";
                break;

            default:
                dieuKienLoc = " ";
                break;
            }
            switch (pi.GroupBy)
            {
            case TypeGroupKiemKe.TYPE:
                data          = ProcedureCollection.KKTongHop(dieuKienLoc, "MALOAIVATTU", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Loại hàng";
                break;

            case TypeGroupKiemKe.WAREHOUSE:
                data          = ProcedureCollection.KKTongHop(dieuKienLoc, "MAKHOHANG", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Kho hàng";
                break;

            case TypeGroupKiemKe.GROUP:
                data          = ProcedureCollection.KKTongHop(dieuKienLoc, "MANHOMVATTU", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Nhóm hàng";
                break;

            case TypeGroupKiemKe.NHACUNGCAP:
                data          = ProcedureCollection.KKTongHop(dieuKienLoc, "MANHACUNGCAP", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Nhà cung cấp";
                break;

            case TypeGroupKiemKe.KEHANG:
                data          = ProcedureCollection.KKTongHop(dieuKienLoc, "MAKEHANG", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Kệ hàng";
                break;

            case TypeGroupKiemKe.MERCHANDISE:
                data          = ProcedureCollection.KKTongHop(dieuKienLoc, "MAVATTU", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Mặt hàng";
                break;

            default:
                data          = ProcedureCollection.KKTongHop(dieuKienLoc, "MAVATTU", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Mặt hàng";
                break;
            }

            return(data);
        }
Exemplo n.º 21
0
        public MemoryStream ExportExcelDetail(ParameterKiemKe pi)
        {
            var itemCollection = new List <NvKiemKeVm.ObjectReportCha>();
            List <NvKiemKeVm.ObjectReportCha> itemCollectionGroup     = new List <NvKiemKeVm.ObjectReportCha>();
            List <BTS.API.SERVICE.NV.NvKiemKeVm.ObjectReportCha> data = new List <BTS.API.SERVICE.NV.NvKiemKeVm.ObjectReportCha>();
            var titleCotName = "";
            var dieuKienLoc  = "";

            switch (pi.ReportType)
            {
            case TypeReportKiemKe.BAOCAOTHUA:
                dieuKienLoc   = "AND NVL(ct.SOLUONGCHENHLECH,0) < 0";
                titleCotName += "(Báo cáo thừa) ";
                break;

            case TypeReportKiemKe.BAOCAOTHIEU:
                dieuKienLoc   = "AND NVL(ct.SOLUONGCHENHLECH,0) > 0";
                titleCotName += "(Báo cáo thiếu) ";
                break;

            default:
                dieuKienLoc = " ";
                break;
            }
            switch (pi.GroupBy)
            {
            case TypeGroupKiemKe.TYPE:
                data          = ProcedureCollection.KKChiTiet(dieuKienLoc, "MALOAIVATTU", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Loại hàng";
                break;

            case TypeGroupKiemKe.WAREHOUSE:
                data          = ProcedureCollection.KKChiTiet(dieuKienLoc, "MAKHOHANG", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Kho hàng";
                break;

            case TypeGroupKiemKe.GROUP:
                data          = ProcedureCollection.KKChiTiet(dieuKienLoc, "MANHOMVATTU", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Nhóm hàng";
                break;

            case TypeGroupKiemKe.NHACUNGCAP:
                data          = ProcedureCollection.KKChiTiet(dieuKienLoc, "MANHACUNGCAP", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Nhà cung cấp";
                break;

            case TypeGroupKiemKe.KEHANG:
                data          = ProcedureCollection.KKChiTiet(dieuKienLoc, "MAKEHANG", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Kệ hàng";
                break;

            case TypeGroupKiemKe.MERCHANDISE:
                data          = ProcedureCollection.KKChiTiet(dieuKienLoc, "MAVATTU", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Mặt hàng";
                break;

            default:
                data          = ProcedureCollection.KKChiTiet(dieuKienLoc, "MAVATTU", pi.WareHouseCodes, pi.MerchandiseTypeCodes, pi.MerchandiseGroupCodes, pi.MerchandiseCodes, pi.NhaCungCapCodes, pi.KeHangCodes, pi.UnitCode, pi.FromDate, pi.ToDate);
                titleCotName += "Mặt hàng";
                break;
            }
            if (data != null)
            {
                itemCollectionGroup.AddRange(data.ToList());
            }

            using (ExcelPackage package = new ExcelPackage())
            {
                var ms = new MemoryStream();
                package.Workbook.Worksheets.Add("Data");
                var worksheet   = package.Workbook.Worksheets[1];
                int startRow    = 6;
                int startColumn = 1;

                ///Header
                ///
                worksheet.Cells[1, 1, 1, 11].Merge = true;
                worksheet.Cells[1, 1].Value        = "NHẬP XUẤT KIỂM KÊ"; worksheet.Cells[1, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                worksheet.Cells[2, 1].Value        =
                    string.Format("Từ ngày: {0}/{1}/{2} Đến ngày: {3}/{4}/{5}",
                                  pi.FromDate.Day, pi.FromDate.Month, pi.FromDate.Year, pi.ToDate.Day, pi.ToDate.Month, pi.ToDate.Year);
                worksheet.Cells[2, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                worksheet.Cells[2, 1, 2, 11].Merge  = true;
                worksheet.Cells[3, 1, 3, 11].Merge  = true;
                worksheet.Cells[4, 1, 5, 1].Merge   = true;
                worksheet.Cells[4, 2, 5, 2].Merge   = true;
                worksheet.Cells[4, 3, 5, 3].Merge   = true;
                worksheet.Cells[4, 4, 5, 4].Merge   = true;
                worksheet.Cells[4, 5, 5, 5].Merge   = true;
                worksheet.Cells[4, 6, 5, 6].Merge   = true;
                worksheet.Cells[4, 11, 5, 11].Merge = true;
                worksheet.Cells[4, 12, 5, 12].Merge = true;
                worksheet.Cells[4, 7, 4, 8].Merge   = true;
                worksheet.Cells[4, 9, 4, 10].Merge  = true;

                worksheet.Cells[3, 1].Value  = "Điều kiện, Nhóm theo: " + titleCotName;
                worksheet.Cells[4, 1].Value  = "STT"; worksheet.Cells[4, 1].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 2].Value  = "Mã"; worksheet.Cells[4, 2].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 3].Value  = "Danh sách"; worksheet.Cells[4, 3].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 4].Value  = "Giá vốn"; worksheet.Cells[4, 4].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 5].Value  = "SL Máy"; worksheet.Cells[4, 5].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 6].Value  = "SL KK"; worksheet.Cells[4, 6].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 7].Value  = "Thừa"; worksheet.Cells[4, 7].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 9].Value  = "Thiếu"; worksheet.Cells[4, 9].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 11].Value = "Ngày KK"; worksheet.Cells[4, 11].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 12].Value = "Barcode"; worksheet.Cells[4, 12].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 8].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[4, 10].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 1].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 2].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 3].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 4].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 5].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 6].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 11].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 12].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 7].Value  = "SL"; worksheet.Cells[5, 7].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 8].Value  = "Giá trị"; worksheet.Cells[5, 8].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 9].Value  = "SL"; worksheet.Cells[5, 9].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                worksheet.Cells[5, 10].Value = "Giá trị"; worksheet.Cells[5, 10].Style.Border.BorderAround(ExcelBorderStyle.Thin);
                var itemTotal  = new NvKiemKeVm.ObjectReport();
                int currentRow = startRow;
                int stt        = 0;

                foreach (var item in itemCollectionGroup)
                {
                    stt = 0;
                    worksheet.Cells[currentRow, 1, currentRow, 12].Merge            = true;
                    worksheet.Cells[currentRow, startColumn].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                    worksheet.Cells[currentRow, startColumn].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(252, 245, 76));
                    worksheet.Cells[currentRow, startColumn].Value = item.Ma + " - " + item.Ten;
                    currentRow++;
                    foreach (var itemdetails in item.DataDetails)
                    {
                        ++stt;
                        worksheet.Cells[currentRow, startColumn].Value      = stt.ToString();
                        worksheet.Cells[currentRow, startColumn + 1].Value  = itemdetails.Ma;
                        worksheet.Cells[currentRow, startColumn + 2].Value  = itemdetails.Ten;
                        worksheet.Cells[currentRow, startColumn + 3].Value  = itemdetails.GiaVon; worksheet.Cells[currentRow, 4].Style.Numberformat.Format = "#,##0.00";
                        worksheet.Cells[currentRow, startColumn + 4].Value  = itemdetails.SoLuongTonMay;
                        worksheet.Cells[currentRow, startColumn + 5].Value  = itemdetails.SoLuongKiemKe;
                        worksheet.Cells[currentRow, startColumn + 6].Value  = itemdetails.SoLuongThua;
                        worksheet.Cells[currentRow, startColumn + 7].Value  = itemdetails.GiaTriThua; worksheet.Cells[currentRow, 8].Style.Numberformat.Format = "#,##0.00";
                        worksheet.Cells[currentRow, startColumn + 8].Value  = itemdetails.SoLuongThieu;
                        worksheet.Cells[currentRow, startColumn + 9].Value  = itemdetails.GiaTriThieu; worksheet.Cells[currentRow, 10].Style.Numberformat.Format = "#,##0.00";
                        worksheet.Cells[currentRow, startColumn + 10].Value = string.Format("{0}/{1}/{2}", itemdetails.NgayKiemKe.Day, itemdetails.NgayKiemKe.Month, itemdetails.NgayKiemKe.Year);
                        worksheet.Cells[currentRow, startColumn + 11].Value = itemdetails.Barcode;
                        worksheet.Cells[currentRow, 1, currentRow, startColumn + 11].Style.Border.BorderAround(ExcelBorderStyle.Dotted);
                        itemTotal.GiaVon        += itemdetails.GiaVon;
                        itemTotal.SoLuongTonMay += itemdetails.SoLuongTonMay;
                        itemTotal.SoLuongKiemKe += itemdetails.SoLuongKiemKe;
                        itemTotal.SoLuongThua   += itemdetails.SoLuongThua;
                        itemTotal.GiaTriThua    += itemdetails.SoLuongThua;
                        itemTotal.SoLuongThieu  += itemdetails.SoLuongThieu;
                        itemTotal.GiaTriThieu   += itemdetails.GiaTriThieu;
                        currentRow++;
                    }
                }
                worksheet.Cells[currentRow, 1, currentRow, startColumn + 2].Merge = true;
                worksheet.Cells[currentRow, startColumn].Value     = "TỔNG CỘNG"; worksheet.Cells[currentRow, startColumn].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                worksheet.Cells[currentRow, startColumn + 3].Value = itemTotal.GiaVon; worksheet.Cells[currentRow, startColumn + 3].Style.Numberformat.Format = "#,##0.00";
                worksheet.Cells[currentRow, startColumn + 4].Value = itemTotal.SoLuongTonMay;
                worksheet.Cells[currentRow, startColumn + 5].Value = itemTotal.SoLuongKiemKe;
                worksheet.Cells[currentRow, startColumn + 6].Value = itemTotal.SoLuongThua;
                worksheet.Cells[currentRow, startColumn + 7].Value = itemTotal.GiaTriThua; worksheet.Cells[currentRow, startColumn + 7].Style.Numberformat.Format = "#,##0.00";
                worksheet.Cells[currentRow, startColumn + 8].Value = itemTotal.SoLuongThieu;
                worksheet.Cells[currentRow, startColumn + 9].Value = itemTotal.GiaTriThieu; worksheet.Cells[currentRow, startColumn + 9].Style.Numberformat.Format = "#,##0.00";
                worksheet.Cells[currentRow, 1, currentRow, startColumn + 11].Style.Border.BorderAround(ExcelBorderStyle.Thin);

                worksheet.Column(1).AutoFit();
                worksheet.Column(2).AutoFit();
                worksheet.Column(3).AutoFit();
                worksheet.Column(4).AutoFit();
                worksheet.Column(5).AutoFit();
                worksheet.Column(6).AutoFit();
                worksheet.Column(7).AutoFit();
                worksheet.Column(8).AutoFit();
                worksheet.Column(9).AutoFit();
                worksheet.Column(10).AutoFit();
                worksheet.Column(11).AutoFit();
                worksheet.Column(12).AutoFit();
                int totalRows = worksheet.Dimension.End.Row;
                int totalCols = worksheet.Dimension.End.Column;
                var dataCells = worksheet.Cells[1, 1, totalRows, totalCols];
                var dataFont  = dataCells.Style.Font;
                dataFont.SetFromFont(new System.Drawing.Font("Times New Roman", 10));
                package.SaveAs(ms);
                return(ms);
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// UpdatePrice
 /// </summary>
 /// <param name="UnitCode"></param>
 /// <param name="FromDate"></param>
 /// <param name="ToDate"></param>
 /// <returns></returns>
 public bool UpdatePrice(string UnitCode, DateTime FromDate, DateTime ToDate)
 {
     return(ProcedureCollection.UpdatePriceByDate(UnitCode, FromDate, ToDate));
 }
Exemplo n.º 23
0
        public HttpResponseMessage ExportExcel(ParameterCashier para)
        {
            var _ParentUnitCode = _service.GetParentUnitCode();

            NvGiaoDichQuayVm.ReportExcel result = null;
            var unitCode = _service.GetCurrentUnitCode();
            //var instance = _service.Repository.DbSet.FirstOrDefault(x => x.MaVatTu.ToUpper() == code.ToUpper());//&& x.UnitCode == unitCode);
            var service = new ProcedureService <NvGiaoDichQuayVm.ReportExcel>();
            var data    = ProcedureCollection.GetReportGDQExcel(para.FromDate, para.ToDate, new BTS.API.ENTITY.ERPContext(), unitCode);

            using (ExcelPackage package = new ExcelPackage())
            {
                var ms = new MemoryStream();
                package.Workbook.Worksheets.Add("Data");
                var worksheet = package.Workbook.Worksheets[1];
                int index     = 0;
                worksheet.Cells[1, 1, 1, 5].Merge = true;
                worksheet.Cells[1, 1].Value       = "SIÊU THỊ TỪ SƠN ";
                worksheet.Cells[2, 1, 2, 5].Merge = true;
                worksheet.Cells[2, 1].Value       = "Đường Lý Thái Tổ, P. Đình Bảng, TX Từ Sơn, Bắc Ninh ";
                worksheet.Cells[4, 4, 4, 7].Merge = true;
                worksheet.Cells[4, 4].Value       = "BÁO CÁO GIAO DỊCH QUẦY ";
                worksheet.Cells[5, 4, 5, 8].Merge = true;
                worksheet.Cells[5, 4].Value       = "Từ ngày: " + para.FromDate.Day + "/" + para.FromDate.Month + "/" + para.FromDate.Year + "   Đến ngày:" + para.ToDate.Day + "/" + para.ToDate.Month + "/" + para.ToDate.Year;
                worksheet.Cells[7, 1].Value       = "STT";
                worksheet.Cells[7, 2].Value       = "Nhân viên";
                worksheet.Cells[7, 3].Value       = "Máy bán";
                worksheet.Cells[7, 4].Value       = "Ngày phát sinh";
                worksheet.Cells[7, 5].Value       = "Loại giao dịch";
                worksheet.Cells[7, 6].Value       = "Mã hàng";
                worksheet.Cells[7, 7].Value       = "Tên hàng";
                worksheet.Cells[7, 8].Value       = "Số lượng";
                worksheet.Cells[7, 9].Value       = "Tổng tiền";
                index = 8;
                if (data != null && data.Count() >= 1)
                {
                    var item = data.ToList();
                    for (int i = 0; i < item.Count; i++)
                    {
                        var hanghoa    = new MdMerchandiseVm.Dto();
                        var innerindex = item[i].MaVatTu;
                        var hanghoatg  = _merchandiseservice.UnitOfWork.Repository <MdMerchandise>().DbSet.FirstOrDefault(x => x.MaVatTu == innerindex && x.UnitCode.StartsWith(_ParentUnitCode));
                        hanghoa = Mapper.Map <MdMerchandise, MdMerchandiseVm.Dto>(hanghoatg);
                        worksheet.Cells[index, 1].Value = index;
                        worksheet.Cells[index, 2].Value = item[i].MaNguoiTao + "-" + item[i].NguoiTao;
                        worksheet.Cells[index, 3].Value = item[i].MaQuayBan;
                        worksheet.Cells[index, 4].Value = item[i].NgayPhatSinh.Date + "/" + item[i].NgayPhatSinh.Month + "/" + item[i].NgayPhatSinh.Year;
                        worksheet.Cells[index, 6].Value = item[i].MaVatTu;
                        if (hanghoa == null)
                        {
                            worksheet.Cells[index, 7].Value = " ";
                        }
                        worksheet.Cells[index, 7].Value = hanghoa.TenHang;
                        worksheet.Cells[index, 8].Value = item[i].SoLuong;
                        worksheet.Cells[index, 9].Value = CurrentSetting.FormatTienViet(item[i].TTienCoVat.ToString());
                        if (item[i].LoaiGiaoDich == 1)
                        {
                            worksheet.Cells[index, 5].Value = "xuất bán";
                        }
                        else if (item[i].LoaiGiaoDich == 2)
                        {
                            worksheet.Cells[index, 5].Value = "bán trả lại";
                        }
                        index++;
                    }
                }
                else
                {
                    //return null;
                }

                package.SaveAs(ms);
                HttpResponseMessage response = Request.CreateResponse();
                response.StatusCode = HttpStatusCode.OK;
                ms.Seek(0, SeekOrigin.Begin);
                response.Content = new StreamContent(ms);

                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
                {
                    FileName = "BaoCaoGiaoDichQuay.xlsx"
                };
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

                return(response);
            }
        }
Exemplo n.º 24
0
 public CallGraph(ProcedureCollection procedures)
 {
     this.procedures = procedures;
 }
Exemplo n.º 25
0
        public async Task <IHttpActionResult> GetDetails(string id)
        {
            var _ParentUnitCode = _service.GetParentUnitCode();
            var result          = new TransferObj <NvXuatKhacVm.Dto>();
            var temp            = new NvXuatKhacVm.Dto();
            var phieu           = _service.FindById(id);

            if (phieu != null)
            {
                temp = Mapper.Map <NvVatTuChungTu, NvXuatKhacVm.Dto>(phieu);
                var chiTietPhieu = _service.UnitOfWork.Repository <NvVatTuChungTuChiTiet>().DbSet.Where(x => x.MaChungTuPk == phieu.MaChungTuPk).ToList();
                temp.DataDetails = Mapper.Map <List <NvVatTuChungTuChiTiet>, List <NvXuatKhacVm.DtoDetail> >(chiTietPhieu);
                temp.DataDetails.ForEach(
                    x =>
                {
                    x.CalcResult();
                    x.GiaVon = x.GiaVon;
                }
                    );
                if (phieu.TrangThai != 10)
                {
                    decimal sum = 0;
                    List <NvXuatKhacVm.DtoDetail> listDetails = new List <NvXuatKhacVm.DtoDetail>();
                    var     unitCode  = _service.GetCurrentUnitCode();
                    var     ky        = CurrentSetting.GetKhoaSo(unitCode);
                    var     tableName = ProcedureCollection.GetTableName(ky.Year, ky.Period);
                    var     MaKho     = temp.MaKhoXuat;
                    decimal giaVon    = 0;
                    //string kyKeToan = _servicePeriod.GetKyKeToan((DateTime)phieu.NgayCT);
                    foreach (var value in temp.DataDetails)
                    {
                        var sp   = _service.UnitOfWork.Repository <MdMerchandisePrice>().DbSet.Where(x => x.MaVatTu.Equals(value.MaHang) && x.MaDonVi.StartsWith(_ParentUnitCode)).FirstOrDefault();
                        var item = _service.UnitOfWork.Repository <MdMerchandise>().DbSet.Where(x => x.MaVatTu.Equals(value.MaHang) && x.UnitCode.StartsWith(_ParentUnitCode)).FirstOrDefault();

                        if (sp != null)
                        {
                            value.TyLeVATVao = sp.TyLeVatVao;
                        }
                        if (item != null)
                        {
                            value.TenHang = item.TenHang;
                        }
                        List <MdMerchandiseVm.DataXNT> data = ProcedureCollection.GetDataInventoryByCondition(unitCode, MaKho, value.MaHang, tableName, _ParentUnitCode);
                        if (data.Count > 0)
                        {
                            decimal.TryParse(value.GiaVon.ToString(), out giaVon);
                            value.DonGia     = giaVon;
                            value.TyLeVATRa  = data[0].TyLeVATRa;
                            value.TyLeVATVao = data[0].TyLeVATVao;
                            value.ThanhTien  = value.DonGia * value.SoLuong;
                            sum += (decimal)value.ThanhTien;
                        }
                        listDetails.Add(value);
                    }
                    temp.DataDetails = listDetails;
                    var tyLe = _service.UnitOfWork.Repository <MdTax>().DbSet.Where(x => x.MaLoaiThue == temp.VAT).Select(x => x.TaxRate).FirstOrDefault();
                    if (tyLe != null)
                    {
                        temp.TienVat = sum * (tyLe / 100);
                    }
                    else
                    {
                        temp.TienVat = 0;
                    }

                    temp.ThanhTienTruocVat = sum;
                    temp.ThanhTienSauVat   = temp.ThanhTienTruocVat + temp.TienVat;
                }
                result.Data   = temp;
                result.Status = true;
                return(Ok(result));
            }
            return(NotFound());
        }
Exemplo n.º 26
0
        public async Task <IHttpActionResult> PostReportInventoryTongHop(ParameterInventory para)
        {
            var result = new TransferObj <InventoryReport>();

            try
            {
                var data     = new List <InventoryExpImpLevel2>();
                var reporter = new InventoryReport();
                reporter.UnitCode = _servicePeriod.GetCurrentUnitCode();
                reporter.Year     = para.ToDate.Year;
                var period = _service.UnitOfWork.Repository <MdPeriod>().DbSet.Where(x => x.ToDate == para.ToDate).FirstOrDefault();
                if (period != null)
                {
                    reporter.Period = period.Period;
                }
                var unitCode = _servicePeriod.GetCurrentUnitCode();
                reporter.CreateDateNow();
                reporter.FromDay     = para.FromDate.Day;
                reporter.FromMonth   = para.FromDate.Month;
                reporter.FromYear    = para.FromDate.Year;
                reporter.ToDay       = para.ToDate.Day;
                reporter.ToMonth     = para.ToDate.Month;
                reporter.ToYear      = para.ToDate.Year;
                reporter.TenDonVi    = CurrentSetting.GetUnitName(unitCode);
                reporter.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
                //GetNhanVien
                if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal)
                {
                    var currentUser = (HttpContext.Current.User as ClaimsPrincipal);
                    var name        = currentUser.Identity.Name;
                    var nhanVien    = _service.UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault();
                    if (nhanVien != null)
                    {
                        reporter.Username = nhanVien.TenNhanVien;
                    }
                    else
                    {
                        reporter.Username = "******";
                    }
                }
                var tableName = ProcedureCollection.GetTableName(period.Year, period.Period);
                data = _service.ReportTonTongHop(para);
                switch (para.GroupBy)
                {
                case TypeGroupInventory.MADONVI:
                    reporter.DetailData = data.ToList();
                    reporter.MapUnitUserName(_service.UnitOfWork);
                    reporter.GroupType = "Mã đơn vị";
                    break;

                case TypeGroupInventory.WAREHOUSE:
                    reporter.DetailData = data.ToList();
                    reporter.MapUnitUserName(_service.UnitOfWork);
                    reporter.GroupType = "Kho hàng";
                    break;

                case TypeGroupInventory.TYPE:
                    reporter.DetailData = data.ToList();
                    reporter.MapUnitUserName(_service.UnitOfWork);
                    reporter.GroupType = "Loại hàng hóa";
                    break;

                case TypeGroupInventory.GROUP:
                    reporter.DetailData = data.ToList();
                    reporter.MapUnitUserName(_service.UnitOfWork);
                    reporter.GroupType = "Nhóm hàng hóa";
                    break;

                case TypeGroupInventory.NHACUNGCAP:
                    reporter.DetailData = data.ToList();
                    reporter.MapUnitUserName(_service.UnitOfWork);
                    reporter.GroupType = "Nhà cung cấp";
                    break;

                default:
                    reporter.DetailData = data.ToList();
                    reporter.MapUnitUserName(_service.UnitOfWork);
                    reporter.GroupType = "Hàng hóa";
                    break;
                }


                result.Data    = reporter;
                result.Status  = true;
                result.Message = "Xuất báo cáo thành công";
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }
Exemplo n.º 27
0
        public NvXuatKhacVm.ReportModel CreateReport(string id)
        {
            var     _ParentUnitCode = GetParentUnitCode();
            var     result          = new NvXuatKhacVm.ReportModel();
            decimal sum             = 0;
            var     exsit           = FindById(id);

            if (exsit != null)
            {
                result = Mapper.Map <NvVatTuChungTu, NvXuatKhacVm.ReportModel>(exsit);
                var nhanvien = UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == exsit.ICreateBy).FirstOrDefault();
                if (nhanvien != null)
                {
                    result.NameNhanVienCreate = nhanvien.TenNhanVien != null ? nhanvien.TenNhanVien : "";
                }
                var detailData = UnitOfWork.Repository <NvVatTuChungTuChiTiet>().DbSet.Where(x => x.MaChungTuPk == exsit.MaChungTuPk).ToList();
                result.DataReportDetails = Mapper.Map <List <NvVatTuChungTuChiTiet>, List <NvXuatKhacVm.ReportDetailModel> >(detailData);
                var sup = UnitOfWork.Repository <MdSupplier>().DbSet.FirstOrDefault(x => x.MaNCC == result.MaKhachHang);
                var cus = UnitOfWork.Repository <MdCustomer>().DbSet.FirstOrDefault(x => x.MaKH == result.MaKhachHang);
                if (sup != null)
                {
                    result.TenKhachHang    = sup.TenNCC;
                    result.DiaChiKhachHang = sup.DiaChi;
                }
                else if (cus != null)
                {
                    result.TenKhachHang    = cus.TenKH;
                    result.DiaChiKhachHang = cus.DiaChi;
                }
                var typeR = UnitOfWork.Repository <MdTypeReason>().DbSet.FirstOrDefault(x => x.MaLyDo == result.MaLyDo);
                if (typeR != null)
                {
                    result.TenLyDo = typeR.TenLyDo;
                }
                if (exsit.TrangThai != 10)
                {
                    List <NvXuatKhacVm.DtoDetail> listDetails = new List <NvXuatKhacVm.DtoDetail>();
                    var ky        = CurrentSetting.GetKhoaSo(exsit.UnitCode);
                    var tableName = ProcedureCollection.GetTableName(ky.Year, ky.Period);
                    var MaKho     = exsit.MaKhoXuat;
                    //string kyKeToan = _servicePeriod.GetKyKeToan((DateTime)phieu.NgayCT);
                    foreach (var value in result.DataReportDetails)
                    {
                        List <MdMerchandiseVm.DataXNT> data = ProcedureCollection.GetDataInventoryByCondition(exsit.UnitCode, MaKho, value.MaHang, tableName, _ParentUnitCode);
                        value.GiaVon    = value.GiaVon;
                        value.DonGia    = value.GiaVon;
                        value.ThanhTien = value.DonGia * value.SoLuong;
                        sum            += (decimal)value.ThanhTien;
                    }
                    var tyLe = UnitOfWork.Repository <MdTax>().DbSet.Where(x => x.MaLoaiThue == exsit.VAT).Select(x => x.TaxRate).FirstOrDefault();
                    if (tyLe != null)
                    {
                        result.TienVat = sum * (tyLe / 100);
                    }
                    else
                    {
                        result.TienVat = 0;
                    }

                    result.ThanhTienTruocVat = sum;
                    result.ThanhTienSauVat   = result.ThanhTienTruocVat + result.TienVat;
                }
                var warehouses      = UnitOfWork.Repository <MdWareHouse>().DbSet;
                var exportWareHouse = warehouses.FirstOrDefault(x => x.MaKho == result.MaKhoXuat);
                result.TenKhoXuat = exportWareHouse != null ? exportWareHouse.TenKho : "";
            }
            var unitCode   = GetCurrentUnitCode();
            var createDate = DateTime.Now;

            result.CreateDay   = createDate.Day;
            result.CreateMonth = createDate.Month;
            result.CreateYear  = createDate.Year;
            result.TenDonVi    = CurrentSetting.GetUnitName(unitCode);
            result.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode);
            //GetNhanVien
            if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal)
            {
                var currentUser = (HttpContext.Current.User as ClaimsPrincipal);
                var name        = currentUser.Identity.Name;
                var nhanVien    = UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault();
                if (nhanVien != null)
                {
                    result.Username = nhanVien.TenNhanVien;
                }
                else
                {
                    result.Username = "******";
                }
            }

            return(result);
        }
Exemplo n.º 28
0
        public async Task <IHttpActionResult> PostDataMerchandise(MdMerchandiseVm.Search dataSearch)
        {
            var result = new TransferObj <MdMerchandiseVm.DtoAndPromotion>();
            //Tạm thời khóa mã đơn vị
            var _unitCode       = _serviceUser.GetCurrentUnitCode();
            var _parentUnitCode = _serviceUser.GetParentUnitCode();
            var _codeWareHouse  = _unitCode + "-K2";

            //trường hợp bán mã cân
            if (dataSearch.MaVatTu.Length > 9 && dataSearch.MaVatTu.Substring(0, 2).Equals("20"))
            {
                try
                {
                    var data = ProcedureCollection.GetBalanceCode(new ERPContext(), dataSearch.MaVatTu);
                    if (data != null && data.Count() == 1)
                    {
                        var    items           = data.ToList();
                        string codeMerchandise = items[0].MaVatTu;
                        result.Data = _serviceRetails.GetDataPromotionByMerchandise(items[0]);
                        //check tồn mã hàng này
                        var xntItem = ProcedureCollection.GetCostOfGoodsSoldByMerchandise(_unitCode, _codeWareHouse,
                                                                                          items[0].MaVatTu);
                        if (xntItem != null)
                        {
                            result.Data.TonCuoiKySl = xntItem.ClosingQuantity == 0 ? 0 : xntItem.ClosingQuantity;
                            result.Data.GiaVon      = xntItem.CostOfCapital == 0 ? 0 : xntItem.CostOfCapital;
                            if (result.Data.TonCuoiKySl <= 0)
                            {
                                result.Data.IsBanAm = true;
                            }
                        }
                        //end check tồn
                        result.Status = true;
                    }
                    else
                    {
                        result.Status  = false;
                        result.Message = "Không tìm thấy sản phẩm này trong danh sách hàng hóa ";
                    }
                }
                catch (Exception ex)
                {
                    return(NotFound());
                }
            }
            //trường hợp bán mã hàng
            else
            {
                try
                {
                    var data = ProcedureCollection.GetMerchandiseAndPromotion(new BTS.API.ENTITY.ERPContext(),
                                                                              dataSearch.MaVatTu, _parentUnitCode);
                    if (data != null && data.Count() == 1)
                    {
                        var    items           = data.ToList();
                        string codeMerchandise = items[0].MaVatTu;
                        result.Data = _serviceRetails.GetDataPromotionByMerchandise(items[0]);
                        //check tồn mã hàng này
                        var xntItem = ProcedureCollection.GetCostOfGoodsSoldByMerchandise(_unitCode, _codeWareHouse, items[0].MaVatTu);
                        if (xntItem != null)
                        {
                            result.Data.TonCuoiKySl = xntItem.ClosingQuantity == 0 ? 0 : xntItem.ClosingQuantity;
                            result.Data.GiaVon      = xntItem.CostOfCapital == 0 ? 0 : xntItem.CostOfCapital;
                            if (result.Data.TonCuoiKySl <= 0)
                            {
                                result.Data.IsBanAm = true;
                            }
                        }
                        // end check tồn
                        result.Status = true;
                    }
                    else
                    {
                        result.Status  = false;
                        result.Message = "Không tìm thấy sản phẩm này !";
                    }
                }
                catch (Exception ex)
                {
                    result.Status = false;
                    result.Data   = new MdMerchandiseVm.DtoAndPromotion();
                    return(Ok(result));
                }
            }
            //}
            return(Ok(result));
        }
Exemplo n.º 29
0
        public HttpResponseMessage ExportExcelSyntheticByCondition(ParameterExcelByCondition para)
        {
            var _ParentUnitCode = _service.GetParentUnitCode();

            NvGiaoDichQuayVm.ReportExcel result = null;
            var unitCode = _service.GetCurrentUnitCode();

            para.UnitCode = unitCode;
            var service = new ProcedureService <NvGiaoDichQuayVm.ReportExcel>();
            var data    = ProcedureCollection.DuLieuTongHopGiaoDichQuayTheoDieuKien(para.TuNgay, para.DenNgay, para.UnitCode, new BTS.API.ENTITY.ERPContext());

            using (ExcelPackage package = new ExcelPackage())
            {
                var ms = new MemoryStream();
                package.Workbook.Worksheets.Add("Data");
                var worksheet = package.Workbook.Worksheets[1];
                int index     = 0;
                worksheet.Cells[1, 1, 1, 5].Merge = true;
                worksheet.Cells[1, 1].Value       = "SIÊU THỊ TỪ SƠN ";
                worksheet.Cells[2, 1, 2, 5].Merge = true;
                worksheet.Cells[2, 1].Value       = "Đường Lý Thái Tổ, P. Đình Bảng, TX Từ Sơn, Bắc Ninh ";
                worksheet.Cells[4, 4, 4, 7].Merge = true;
                worksheet.Cells[4, 4].Value       = "BÁO CÁO GIAO DỊCH QUẦY TỔNG HỢP ";
                worksheet.Cells[5, 4, 5, 8].Merge = true;
                worksheet.Cells[5, 4].Value       = "Từ ngày: " + para.TuNgay.Day + "/" + para.TuNgay.Month + "/" + para.TuNgay.Year + "   Đến ngày:" + para.DenNgay.Day + "/" + para.DenNgay.Month + "/" + para.DenNgay.Year;
                worksheet.Cells[7, 1].Value       = "STT";
                worksheet.Cells[7, 2].Value       = "Mã giao dịch";
                worksheet.Cells[7, 3].Value       = "Mã giao dịch PK";
                worksheet.Cells[7, 4].Value       = "Loại giao dịch";
                worksheet.Cells[7, 5].Value       = "Tổng tiền";
                int stt = 1;
                index = 8;
                if (data != null && data.Count() >= 1)
                {
                    var item = data.ToList();
                    for (int i = 0; i < item.Count; i++)
                    {
                        var hanghoa    = new MdMerchandiseVm.Dto();
                        var innerindex = item[i].MaVatTu;
                        var hanghoatg  = _merchandiseservice.UnitOfWork.Repository <MdMerchandise>().DbSet.FirstOrDefault(x => x.MaVatTu == innerindex && x.UnitCode.StartsWith(_ParentUnitCode));
                        hanghoa = Mapper.Map <MdMerchandise, MdMerchandiseVm.Dto>(hanghoatg);
                        worksheet.Cells[index, 1].Value = stt;
                        worksheet.Cells[index, 2].Value = item[i].MaGiaoDich;
                        worksheet.Cells[index, 3].Value = item[i].MaGiaoDichQuayPK;
                        if (item[i].LoaiGiaoDich == 1)
                        {
                            worksheet.Cells[index, 4].Value = "Bán lẻ";
                        }
                        else if (item[i].LoaiGiaoDich == 2)
                        {
                            worksheet.Cells[index, 4].Value = "Trả lại";
                        }
                        worksheet.Cells[index, 5].Value = CurrentSetting.FormatTienViet(item[i].TTienCoVat.ToString());
                        index++;
                        stt++;
                    }
                }
                else
                {
                    //return null;
                }

                package.SaveAs(ms);
                HttpResponseMessage response = Request.CreateResponse();
                response.StatusCode = HttpStatusCode.OK;
                ms.Seek(0, SeekOrigin.Begin);
                response.Content = new StreamContent(ms);

                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
                {
                    FileName = "BaoCaoGiaoDichQuayTongHop.xlsx"
                };
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

                return(response);
            }
        }
Exemplo n.º 30
0
        public bool UpDateGiaVon(MdPeriod instance)
        {
            var tableName = instance.GetTableName();

            return(ProcedureCollection.CapNhatGiaVonQuayGiaoDich(tableName, instance.UnitCode, instance.ToDate));
        }