示例#1
0
        private string ValidateDataImport(Excel.Row row)
        {
            bool   flag = false;
            string msg  = string.Empty;

            for (int i = 0; i < row.Cells.Count(); i++)
            {
                if (row.Cells[i] != null && !string.IsNullOrEmpty(row.Cells[i].Text))
                {
                    flag = true;
                    break;
                }
            }

            if (flag)
            {
                if (row.Cells[0] == null || string.IsNullOrEmpty(row.Cells[0].Text.Trim()))
                {
                    msg += "    - Tên bác sỹ không được bỏ trống <br/>";
                }

                return(string.IsNullOrEmpty(msg) ? Constants.Params.msgOk : msg);
            }
            else
            {
                return(string.Empty);
            }
        }
示例#2
0
        private BacSy Bindbacsy(ref BacSy bacsy, Excel.Row row)
        {
            //
            //Bindding Cac thong tin
            //
            var tenbacsy = row.Cells[0] != null ? row.Cells[0].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(tenbacsy))
            {
                bacsy.TenBacSy = tenbacsy;
            }
            //
            var sodienthoai = row.Cells[2] != null ? row.Cells[2].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(sodienthoai))
            {
                bacsy.DienThoai = sodienthoai;
            }
            //
            var diachi = row.Cells[1] != null ? row.Cells[1].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(diachi))
            {
                bacsy.DiaChi = diachi;
            }
            //
            var email = row.Cells[3] != null ? row.Cells[3].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(email))
            {
                bacsy.Email = email;
            }

            return(bacsy);
        }
示例#3
0
        private string ValidateDataImport(Excel.Row row)
        {
            bool   flag = false;
            string msg  = string.Empty;

            for (int i = 0; i < row.Cells.Count(); i++)
            {
                if (row.Cells[i] != null && !string.IsNullOrEmpty(row.Cells[i].Text))
                {
                    flag = true;
                    break;
                }
            }

            if (flag)
            {
                decimal tmp = 0;
                if (row.Cells[0] == null || string.IsNullOrEmpty(row.Cells[0].Text.Trim()))
                {
                    msg += "    - Nhóm nhà cung cấp không được bỏ trống <br/>";
                }

                if (row.Cells[1] == null || string.IsNullOrEmpty(row.Cells[1].Text.Trim()))
                {
                    msg += "    - Tên nhà cung cấp không được bỏ trống <br/>";
                }

                if (row.Cells[4] != null && !string.IsNullOrEmpty(row.Cells[4].Text.Trim()) && !decimal.TryParse(row.Cells[4].Value.Trim(), out tmp))
                {
                    msg += "    - Số dư đầu kỳ phải là số <br/>";
                }

                return(string.IsNullOrEmpty(msg) ? Constants.Params.msgOk : msg);
            }
            else
            {
                return(string.Empty);
            }
        }
示例#4
0
        private NhaCungCap BindNhaCungCap(ref NhaCungCap nhacungcap, Excel.Row row)
        {
            var maNhaThuoc = this.GetNhaThuoc().MaNhaThuoc;
            //Nhom nha cung cap
            var tennhomnhacungcap = sThuoc.Utils.Helpers.RemoveEncoding(row.Cells[0].Text.Trim());
            var nhomnhacungcap    = unitOfWork.NhomNhaCungCapRepository.GetMany(x => x.MaNhaThuoc == maNhaThuoc && x.TenNhomNhaCungCap == tennhomnhacungcap).FirstOrDefault();

            if (nhomnhacungcap == null && !String.IsNullOrEmpty(tennhomnhacungcap))
            {
                nhomnhacungcap = new NhomNhaCungCap
                {
                    TenNhomNhaCungCap = tennhomnhacungcap,
                    NhaThuoc          = unitOfWork.NhaThuocRepository.GetById(maNhaThuoc),
                    MaNhomNhaCungCap  = 0,
                    GhiChu            = "",
                    CreatedBy         = unitOfWork.UserProfileRepository.GetById(WebSecurity.GetCurrentUserId),
                    Created           = DateTime.Now
                };

                unitOfWork.NhomNhaCungCapRepository.Insert(nhomnhacungcap);
                unitOfWork.Save();
            }
            if (nhomnhacungcap != null)
            {
                nhacungcap.NhomNhaCungCap = nhomnhacungcap;
            }
            //
            //Bindding Cac thong tin
            //
            var tennhacungcap = row.Cells[1].Text.Trim();

            if (!String.IsNullOrWhiteSpace(tennhacungcap))
            {
                nhacungcap.TenNhaCungCap = tennhacungcap;
            }
            //
            var sodienthoai = row.Cells[3] != null ? row.Cells[3].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(sodienthoai))
            {
                nhacungcap.SoDienThoai = sodienthoai;
            }
            //
            var diachi = row.Cells[2] != null ? row.Cells[2].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(diachi))
            {
                nhacungcap.DiaChi = diachi;
            }
            //
            var nodauky = (row.Cells[4] != null && !string.IsNullOrEmpty(row.Cells[4].Text.Trim())) ? Convert.ToDecimal(row.Cells[4].Value.Trim()) : 0;

            nhacungcap.NoDauKy = nodauky;
            //
            var sofax = row.Cells[5] != null ? row.Cells[5].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(sofax))
            {
                nhacungcap.SoFax = sofax;
            }
            //
            var masothue = row.Cells[6] != null ? row.Cells[6].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(masothue))
            {
                nhacungcap.MaSoThue = masothue;
            }
            //
            var nguoidaidien = row.Cells[7] != null ? row.Cells[7].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(nguoidaidien))
            {
                nhacungcap.NguoiDaiDien = nguoidaidien;
            }
            //
            var nguoilienhe = row.Cells[8] != null ? row.Cells[8].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(nguoilienhe))
            {
                nhacungcap.NguoiLienHe = nguoilienhe;
            }
            //
            var email = row.Cells[9] != null ? row.Cells[9].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(email))
            {
                nhacungcap.Email = email;
            }

            return(nhacungcap);
        }
示例#5
0
        private KhachHang BindKhachHang(ref KhachHang khachhang, Excel.Row row)
        {
            var maNhaThuoc = this.GetNhaThuoc().MaNhaThuoc;
            //Nhom khach hang
            var tenNhomKhacHang = sThuoc.Utils.Helpers.RemoveEncoding(row.Cells[0].Text.Trim());
            var nhomKhachHang   = unitOfWork.NhomKhachHangRepository.GetMany(x => x.NhaThuoc.MaNhaThuoc == maNhaThuoc && x.TenNhomKhachHang.ToUpper() == tenNhomKhacHang.ToUpper()).FirstOrDefault();

            if (nhomKhachHang == null && !String.IsNullOrEmpty(tenNhomKhacHang))
            {
                nhomKhachHang = new NhomKhachHang
                {
                    TenNhomKhachHang = tenNhomKhacHang,
                    NhaThuoc         = unitOfWork.NhaThuocRepository.GetById(this.GetNhaThuoc().MaNhaThuoc),
                    MaNhomKhachHang  = 0,
                    GhiChu           = "",
                    Created          = DateTime.Now,
                    CreatedBy        = unitOfWork.UserProfileRepository.GetById(WebSecurity.GetCurrentUserId)
                };

                unitOfWork.NhomKhachHangRepository.Insert(nhomKhachHang);
                unitOfWork.Save();
            }
            if (nhomKhachHang != null)
            {
                khachhang.NhomKhachHang = nhomKhachHang;
            }
            //
            //Cac thong tin con lai
            //
            var TenKhachHang = row.Cells[1].Text.Trim();

            if (!String.IsNullOrWhiteSpace(TenKhachHang))
            {
                khachhang.TenKhachHang = TenKhachHang;
            }
            //
            var SoDienThoai = row.Cells[3] != null ? row.Cells[3].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(SoDienThoai))
            {
                khachhang.SoDienThoai = SoDienThoai;
            }
            //
            var DiaChi = row.Cells[2] != null ? row.Cells[2].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(DiaChi))
            {
                khachhang.DiaChi = DiaChi;
            }
            //
            var NodauKy = row.Cells[4] != null?Convert.ToDecimal(row.Cells[4].Text.Trim()) : 0;

            khachhang.NoDauKy = NodauKy;
            //
            var DonViCongTac = row.Cells[5] != null ? row.Cells[5].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(DonViCongTac))
            {
                khachhang.DonViCongTac = DonViCongTac;
            }
            //
            var Email = row.Cells[6] != null ? row.Cells[6].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(Email))
            {
                khachhang.Email = Email;
            }
            //
            var GhiChu = row.Cells[7] != null ? row.Cells[7].Text.Trim() : string.Empty;

            if (!String.IsNullOrWhiteSpace(GhiChu))
            {
                khachhang.GhiChu = GhiChu;
            }

            return(khachhang);
        }