Esempio n. 1
0
 public static string DeleteItem(int itemID)
 {
     try
     {
         //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace
         xRPDataContext dts           = new xRPDataContext();
         Guid           currentUserID = Guid.NewGuid();
         string         currentUser   = "";
         #region Get current User
         MembershipUser membershipUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
         if (membershipUser != null)
         {
             currentUser   = membershipUser.UserName;
             currentUserID = (Guid)membershipUser.ProviderUserKey;
         }
         #endregion get current User
         dts.Sp_Qlvt_NhaCungCap_Deli("DEL1", itemID, currentUserID, Util.GetIP(), Util.GetPCName());
         //Qlvt_NhaCungCap nhacc = (from t in dts.Qlvt_NhaCungCaps where t.ID == itemID select t).FirstOrDefault();
         //if (nhacc != null) //Check for item exists
         //{
         //    dts.Qlvt_NhaCungCaps.DeleteOnSubmit(nhacc); //Call delete.
         //    dts.SubmitChanges(); // Submit change to data context.
         //}
     }
     catch (Exception)
     {
         return("ERROR");
     }
     return("SUCCESS");
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            string URL = Attributes["param"];

            ID_HeSoTongGiao = Util.GetParam(URL, "id");
            trang           = Util.GetParam(URL, "trang");
            if (ID_HeSoTongGiao != "" && ID_HeSoTongGiao != "-1")
            {
                int              id          = int.Parse(ID_HeSoTongGiao);
                xRPDataContext   datacontext = new xRPDataContext();
                Qldh_HeSoTongDao hstg        = (from c in datacontext.Qldh_HeSoTongDaos where c.ID == id select c).FirstOrDefault();
                txtGhiChu.Text       = hstg.GhiChu;
                txtHeSoTongGiao.Text = hstg.HeSoTongDao.ToString();
                txtSoLop.Text        = hstg.SoLop.ToString();
                slcKichThuoc.Value   = hstg.IDLoaiKichThuoc.ToString();
                Qldh_LoaiKichThuoc lkt = (from d in datacontext.Qldh_LoaiKichThuocs where d.ID == hstg.IDLoaiKichThuoc select d).FirstOrDefault();
                if (lkt != null)
                {
                    txtKichThuoc.Text = lkt.MaHieuKichThuoc.Trim() + "_" + lkt.LoaiKichThuoc;
                }
                if (hstg.KichHoat.Value == true)
                {
                    chkKichHoat.Checked = true;
                }
                if (hstg.KichHoat.Value == false)
                {
                    chkKichHoat.Checked = false;
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string URL = Attributes["param"];

            ID_Song = Util.GetParam(URL, "id");
            trang   = Util.GetParam(URL, "trang");

            if (ID_Song != "" && ID_Song != "-1")
            {
                int              id          = int.Parse(ID_Song);
                xRPDataContext   datacontext = new xRPDataContext();
                Qldh_DanhMucSong qlkh        = (from c in datacontext.Qldh_DanhMucSongs where c.ID == id select c).FirstOrDefault();
                txtTenSong.Text     = qlkh.TenSong;
                txtGhiChu.Text      = qlkh.GhiChu;
                txtHeSoTieuHao.Text = qlkh.HeSoTieuHao.ToString();
                if (qlkh.KichHoat.Value == true)
                {
                    chkKichHoat.Checked = true;
                }
                if (qlkh.KichHoat.Value == false)
                {
                    chkKichHoat.Checked = false;
                }
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Attributes["param"] != null)
            {
                string URL = Attributes["param"];
                ID_NhaCungCap = Util.GetParam(URL, "id");
                trang         = Util.GetParam(URL, "trang");
                if (ID_NhaCungCap != "" && ID_NhaCungCap != "-1")
                {
                    int            id  = int.Parse(ID_NhaCungCap);
                    xRPDataContext xrp = new xRPDataContext();

                    Qlvt_NhaCungCap qlncc = (from c in xrp.Qlvt_NhaCungCaps where c.ID == id select c).FirstOrDefault();

                    txtMaNCC.Text             = qlncc.MaHieuNhaCungCap;
                    txtTenNhaCungCap.Text     = qlncc.TenNhaCungCap;
                    txtDiaChiNhaCungCap.Text  = qlncc.DiaChi;
                    txtSoDienThoaiLienHe.Text = qlncc.DienThoaiLienHe;
                    txtSoMayFax.Text          = qlncc.SoFax;
                    txtEmail.Text             = qlncc.Email;
                    txtTaiKhoanNganHang.Text  = qlncc.SoTaiKhoan;
                    txtMoTaiNganHang.Text     = qlncc.NganHang;
                    txtDiaChiWebsite.Text     = qlncc.Url;
                    txtGhiChu.Text            = qlncc.GhiChu;
                    if (qlncc.KichHoat.Value == true)
                    {
                        ckKichHoat.Checked = true;
                    }
                    if (qlncc.KichHoat.Value == false)
                    {
                        ckKichHoat.Checked = false;
                    }
                }
            }
        }
Esempio n. 5
0
        public string GetMaLoaiVatTuJSONData(int maVatTu)
        {
            xRPDataContext dts  = new xRPDataContext();
            string         data = "[]";

            try
            {
                var vatTu = dts.Sp_Qlvt_VatTu_Select(2, maVatTu, (int?)null, (int?)null).FirstOrDefault();
                if (vatTu == null)
                {
                    return("{\"ERROR\":\"Vật tư không tồn tại.\"}");
                }

                List <object> list = new List <object>();
                foreach (var lvt in dts.Sp_Qlvt_LoaiVatTu_Select(1, vatTu.MaLoaiVatTu, "", (int?)null, (int?)null))
                {
                    list.Add(new
                    {
                        data = lvt.MaHieuLoaiVatTu
                    });
                }
                data = new JavaScriptSerializer().Serialize(list);
            }
            catch (Exception ex)
            {
                data = "{error:\"" + ex.Message + "\"}";
            }
            return(data);
        }
Esempio n. 6
0
        public static string GetThanhPhamXuat(int idPhieuXuat)
        {
            var dtc = new xRPDataContext();

            var dataa = dtc.Sp_Qlvt_ThanhPhamXuat_Select(2, null, idPhieuXuat, null, "").ToList();

            var lsData = (from p in dtc.Sp_Qlvt_ThanhPhamXuat_Select(2, null, idPhieuXuat, null, "")
                          join mh in dtc.Qldh_MatHangs on p.IDMatHang equals mh.ID
                          select new
            {
                itemID = p.ID,
                idPhieuXuat = idPhieuXuat,
                iDMatHang = mh.ID,
                tenMatHang = mh.TenMatHang,
                tenXuatBan = p.TenXuatBan,
                dai = mh.ChieuDai,
                rong = mh.ChieuRong,
                cao = mh.ChieuCao,
                soLop = mh.SoLop,
                loaiSanPham = mh.Qldh_LoaiSanPham.TenLoaiSanPham,
                loaiKichThuoc = mh.Qldh_LoaiKichThuoc.LoaiKichThuoc,
                soLuongXuat = p.SoLuongXuat,
                iDDonViTinh = p.IDDonViTinh,
                donViTinh = dtc.Qlvt_DonViTinhs.FirstOrDefault(t => t.ID == p.IDDonViTinh).DonViTinh,
                donGia = p.DonGia,
                thanhTien = p.ThanhTien,
                tinhTrang = p.TinhTrang
            }).Distinct().ToList();

            string data = new JavaScriptSerializer().Serialize(lsData);

            return(data);
        }
Esempio n. 7
0
        public static string GetThanhPhamNhap(int idPhieuNhap)
        {
            var dtc    = new xRPDataContext();
            var lsData = (from p in dtc.Sp_Qlvt_ThanhPhamNhap_Select(2, null, idPhieuNhap, null)
                          join mh in dtc.Qldh_MatHangs on p.IDMatHang equals mh.ID
                          //join lkt in dtc.Qldh_LoaiKichThuocs on mh.IDLoaiKichThuoc equals lkt.ID
                          //join lsp in dtc.Qldh_LoaiSanPhams on mh.IDLoaiSanPham equals lsp.ID
                          //join dvt in dtc.Qlvt_DonViTinhs on p.IDDonViTinh equals dvt.ID
                          select new
            {
                itemID = p.ID,
                iDPhieuNhap = idPhieuNhap,
                iDMatHang = mh.ID,
                maHieuMatHang = mh.MaHieuMatHang,
                tenMatHang = mh.TenMatHang,
                dai = mh.ChieuDai,
                rong = mh.ChieuRong,
                cao = mh.ChieuCao,
                soLop = mh.SoLop,
                loaiSanPham = mh.Qldh_LoaiSanPham.TenLoaiSanPham,
                loaiKichThuoc = mh.Qldh_LoaiKichThuoc.LoaiKichThuoc,
                soLuongNhap = p.SoLuongNhap,
                iDDonViTinh = p.IDDonViTinh,
                donViTinh = dtc.Qlvt_DonViTinhs.FirstOrDefault(t => t.ID == p.IDDonViTinh).DonViTinh,
                donGia = p.DonGia,
                thanhTien = p.ThanhTien,
                tinhTrang = p.TinhTrang
            }).ToList();



            string data = new JavaScriptSerializer().Serialize(lsData);

            return(data);
        }
Esempio n. 8
0
        private void LoadData(int id)
        {
            try
            {
                xRPDataContext dts = new xRPDataContext();
                this.currentPhieuNhapThanhPham = (from t in dts.Qlvt_ThanhPhamNhaps where t.ID == id select t).FirstOrDefault();
                if (this.currentPhieuNhapThanhPham != null)
                {
                    txtIDMatHang.Text  = dts.Qldh_MatHangs.FirstOrDefault(p => p.ID == this.currentPhieuNhapThanhPham.IDMatHang).MaHieuMatHang + " - " + dts.Qldh_MatHangs.FirstOrDefault(p => p.ID == this.currentPhieuNhapThanhPham.IDMatHang).TenMatHang;
                    slcIDMatHang.Value = this.currentPhieuNhapThanhPham.IDMatHang.ToString();

                    txtIDDonViTinh.Text  = dts.Qlvt_DonViTinhs.FirstOrDefault(p => p.ID == this.currentPhieuNhapThanhPham.IDDonViTinh).DonViTinh;
                    slcIDDonViTinh.Value = this.currentPhieuNhapThanhPham.IDDonViTinh.ToString();

                    txtDonGia.Text    = this.currentPhieuNhapThanhPham.DonGia.ToString();
                    txtThanhTien.Text = this.currentPhieuNhapThanhPham.ThanhTien.ToString();
                    tinhtrang         = this.currentPhieuNhapThanhPham.TinhTrang.ToString();
                    txtRandom.Value   = "-1";//Đã tồn tại giá trị trong hệ thống.
                }
                else
                {
                    tinhtrang = "0";
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.StackTrace);
                Response.Write(ex.Message);
            }
        }
Esempio n. 9
0
        private void LoadData(int id)
        {
            try
            {
                xRPDataContext dts = new xRPDataContext();
                this.currentPhieuXuatThanhPham = (from t in dts.Qlvt_ThanhPhamXuats where t.ID == id select t).FirstOrDefault();

                if (this.currentPhieuXuatThanhPham != null)
                {
                    //  txtIDPhieuXuat.Text = dts.Qlvt_PhieuXuats.FirstOrDefault(p => p.ID == this.currentPhieuXuatThanhPham.IDPhieuXuat).MaHieuPhieuXuat;
                    //  slcIDPhieuXuat.Value = this.currentPhieuXuatThanhPham.IDPhieuXuat.ToString();
                    txtIDMatHang.Text    = dts.Qldh_MatHangs.FirstOrDefault(p => p.ID == this.currentPhieuXuatThanhPham.IDMatHang).TenMatHang;
                    slcIDMatHang.Value   = this.currentPhieuXuatThanhPham.IDMatHang.ToString();
                    txtIDDonViTinh.Text  = dts.Qlvt_DonViTinhs.FirstOrDefault(p => p.ID == this.currentPhieuXuatThanhPham.IDDonViTinh).DonViTinh;
                    slcIDDonViTinh.Value = this.currentPhieuXuatThanhPham.IDDonViTinh.ToString();
                    txtSoLuongXuat.Text  = this.currentPhieuXuatThanhPham.SoLuongXuat.ToString();
                    txtDonGia.Text       = this.currentPhieuXuatThanhPham.DonGia.ToString();
                    txtThanhTien.Text    = this.currentPhieuXuatThanhPham.ThanhTien.ToString();
                    tinhtrang            = this.currentPhieuXuatThanhPham.TinhTrang.ToString();
                }
                else
                {
                    tinhtrang = "0";
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.StackTrace);
                Response.Write(ex.Message);
            }
        }
Esempio n. 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string URL = Attributes["param"];

            ID_LoaiSanPham = Util.GetParam(URL, "id");
            trang          = Util.GetParam(URL, "trang");

            if (ID_LoaiSanPham != "" && ID_LoaiSanPham != "-1")
            {
                int              id          = int.Parse(ID_LoaiSanPham);
                xRPDataContext   datacontext = new xRPDataContext();
                Qldh_LoaiSanPham qlkh        = (from c in datacontext.Qldh_LoaiSanPhams where c.ID == id select c).FirstOrDefault();

                txtTenLoaiSanPham.Text = qlkh.TenLoaiSanPham;
                txtGhiChu.Text         = qlkh.GhiChu;
                txtCongThuc.Text       = qlkh.CongThucTinhDienTichSanPham;
                if (qlkh.KichHoat.Value == true)
                {
                    chkKichHoat.Checked = true;
                }
                if (qlkh.KichHoat.Value == false)
                {
                    chkKichHoat.Checked = false;
                }
            }
        }
Esempio n. 11
0
        protected void LoadBaoCaoNhapXuatTon(string lsKhoId, string lsLoaiVatTuId, string lsVatTuId, DateTime?ngayBatDau, DateTime?ngayKetThuc)
        {
            using (var dts = new xRPDataContext())
            {
                ///Đường đẫn file report.
                rpViewerData.LocalReport.ReportPath = "Report/QuanLyVatTu/NhapXuatTon/ReportNhapXuatTonTheoChiTietVatTu.rdlc";

                var data = dts.Sp_Qlvt_BaoCaoNhapXuatTonTheoVatTu(String.IsNullOrEmpty(lsKhoId) == true ? null : lsKhoId,
                                                                  String.IsNullOrEmpty(lsLoaiVatTuId) == true ? null : lsLoaiVatTuId,
                                                                  String.IsNullOrEmpty(lsVatTuId) == true ? null : lsVatTuId, "0",
                                                                  ngayBatDau, ngayKetThuc).ToList();

                ReportDataSource rpt = new ReportDataSource("dtsNhapXuatTon", data);
                rpViewerData.LocalReport.DataSources.Clear();
                rpViewerData.LocalReport.DataSources.Add(rpt);
                rpViewerData.LocalReport.Refresh();

                ReportParameter[] p = new ReportParameter[3];
                p[0] = new ReportParameter("tencongty", repThongSoHeThong.TenCongTy.ToUpper());
                p[1] = new ReportParameter("diachi", repThongSoHeThong.DiaChiCongTy.ToUpper());
                p[2] = new ReportParameter("sodienthoai", repThongSoHeThong.DienThoaiLienHe.ToUpper());
                // p[3] = new ReportParameter("sodienthoai", ngaysanxuat);
                rpViewerData.LocalReport.SetParameters(p);
            }
        }
Esempio n. 12
0
        public static string XoaKho(int id)
        {
            try
            {
                Guid   currentUserID = Guid.NewGuid();
                string currentUser   = "";
                #region Get current User
                MembershipUser membershipUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
                if (membershipUser != null)
                {
                    currentUser   = membershipUser.UserName;
                    currentUserID = (Guid)membershipUser.ProviderUserKey;
                }
                #endregion get current User

                xRPDataContext xrp = new xRPDataContext();
                xrp.Sp_Qlvt_KhoVatTu_Deli("DEL1", id, currentUserID, Util.GetIP(), Util.GetPCName());
                // Qlvt_KhoVatTu qltcxn = (from c in xrp.Qlvt_KhoVatTus where c.ID == id select c).FirstOrDefault();
                //qltcxn.Xoa = true;
                //xrp.SubmitChanges();
            }
            catch (Exception)
            {
                return("ERROR");
            }
            return("SUCCESS");
        }
Esempio n. 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["trang"] != null)
            {
                trang = Request.QueryString["trang"].ToString();
            }
            if (string.IsNullOrEmpty(trang))
            {
                trang = "1";
            }

            int.TryParse(trang, out pageIndex);
            StartIndex = pageSize * (pageIndex - 1);

            //Sys_UserLogRepository repository = new Sys_UserLogRepository();
            ////List<Sys_Log> data = repository.GetTable().OrderByDescending(x => x.ThoiGianThucHien).ToList();
            //List<Sys_UserLog> data = new List<Sys_UserLog>();
            xRPDataContext dataContext = new xRPDataContext();
            List <Sp_Qlht_NhatKyHeThong_SelectResult> data = dataContext.Sp_Qlht_NhatKyHeThong_Select().ToList();

            CollectionPager1.MaxPages      = 10000;
            CollectionPager1.PageSize      = 20; // số items hiển thị trên một trang.
            CollectionPager1.DataSource    = data;
            CollectionPager1.BindToControl = rptData;
            rptData.DataSource             = CollectionPager1.DataSourcePaged;
            rptData.DataBind();
        }
Esempio n. 14
0
        public static string GetVatTuXuat(int idPhieuXuat)
        {
            List <xRPDAL.Sp_Qlvt_VatTuXuat_SelectResult> vtn = new xRPDataContext().Sp_Qlvt_VatTuXuat_Select(2, (int?)null, idPhieuXuat, 0).ToList();
            string data = new JavaScriptSerializer().Serialize(vtn);

            return(data);
        }
Esempio n. 15
0
        public static string UpdateNhaCungCap(string id, string manhacc, string tennhacungcap,
                                              string diaChi, string sodienthoai, string somayfax, string email, string taikhoannganhang, string motainganhang, string diachiweb,
                                              string kichhoat, string ghichu)
        {
            Guid   currentUserID = Guid.NewGuid();
            string currentUser   = "";

            #region Get current User
            MembershipUser membershipUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
            if (membershipUser != null)
            {
                currentUser   = membershipUser.UserName;
                currentUserID = (Guid)membershipUser.ProviderUserKey;
            }
            #endregion get current User
            xRPDataContext  nhacungcap    = new xRPDataContext();
            Qlvt_NhaCungCap dalnhacungcap = new Qlvt_NhaCungCap();
            int?            idd           = int.Parse(id) == 0 || int.Parse(id) == -1 ? (int?)null : int.Parse(id);
            try
            {
                if (int.Parse(id) == -1)
                {
                    nhacungcap.Sp_Qlvt_NhaCungCap_Add_Edit_Deli("ADD", int.Parse(id), manhacc, tennhacungcap, diaChi, sodienthoai, taikhoannganhang, motainganhang, email, somayfax, diachiweb, ghichu, int.Parse(kichhoat), currentUserID, currentUserID, ref idd, Util.GetIP(), Util.GetPCName());
                }
                if (int.Parse(id) > 0)
                {
                    nhacungcap.Sp_Qlvt_NhaCungCap_Add_Edit_Deli("EDIT", int.Parse(id), manhacc, tennhacungcap, diaChi, sodienthoai, taikhoannganhang, motainganhang, email, somayfax, diachiweb, ghichu, int.Parse(kichhoat), currentUserID, currentUserID, ref idd, Util.GetIP(), Util.GetPCName());
                }
            }
            catch (Exception)
            {
                return("ERROR");
            }
            return("SUCCESS");
        }
Esempio n. 16
0
        public string GetJSONData()
        {
            xRPDataContext dts  = new xRPDataContext();
            string         data = "[]";

            try
            {
                List <object> list = new List <object>();
                foreach (var vt in dts.Sp_Qlvt_VatTu_Select(0, (int?)null, (int?)null, (int?)null))
                {
                    list.Add(new
                    {
                        ID                 = vt.ID,
                        MaVatTu            = vt.MaHieuVatTu,
                        TenVatTu           = vt.TenVatTu,
                        DonViTinh          = vt.DonViTinh,
                        DinhLuongTieuChuan = vt.DinhLuong,
                        KichThuocTieuChuan = vt.KichThuocVatTu
                    });
                }
                data = new JavaScriptSerializer().Serialize(list);
            }
            catch (Exception ex)
            {
                data = "{error:\"" + ex.Message + "\"}";
            }
            return(data);
        }
Esempio n. 17
0
        protected void FillData(int id)
        {
            var dbContext = new xRPDataContext();
            var item      = dbContext.Qlvt_VatTus.FirstOrDefault(i => i.ID == id);

            if (item != null)
            {
                //-----Fill and selected cbo----
                BindCbo(item.MaLoaiVatTu.Value);
                //-------------------------------
                txtDinhLuong.Text = item.DinhLuong.ToString();
                //txtDonViTinh.Text = item.DonViTinh;
                txtDonViTinh.Text      = new xRPDataContext().Qlvt_DonViTinhs.FirstOrDefault(i => i.ID == item.IDDonViTinh).DonViTinh;
                hdfDonViTinh.Value     = item.IDDonViTinh.ToString();
                txtGhiChu.Text         = item.GhiChu;
                txtKichThuocVatTu.Text = item.KichThuocVatTu.ToString();
                txtMaVatTu.Text        = item.MaHieuVatTu;
                txtTenVatTu.Text       = item.TenVatTu;
                txtTonToiThieu.Text    = item.SoLuongTonToiThieu.Value.ToString();
                try
                {
                    chkKichHoat.Checked = item.KichHoat.Value;
                }
                catch
                {
                    chkKichHoat.Checked = false;
                }
            }
            dbContext.Dispose();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string URL = Attributes["param"];

            ID_NhomKhachHang = Util.GetParam(URL, "id");
            trang            = Util.GetParam(URL, "trang");

            if (ID_NhomKhachHang != "" && ID_NhomKhachHang != "-1")
            {
                int                id            = int.Parse(ID_NhomKhachHang);
                xRPDataContext     nhomKhachHang = new xRPDataContext();
                Qldh_NhomKhachHang qlkh          = (from c in nhomKhachHang.Qldh_NhomKhachHangs where c.ID == id select c).FirstOrDefault();
                txtNhomKhachHang.Text = qlkh.TenNhomKhachHang;
                txtGhiChu.Text        = qlkh.GhiChu;

                if (qlkh.KichHoat.Value == true)
                {
                    chkKichHoat.Checked = true;
                }
                if (qlkh.KichHoat.Value == false)
                {
                    chkKichHoat.Checked = false;
                }
            }
        }
Esempio n. 19
0
        public static string ThemDonViTinh(string id, string tenTinhChat)
        {
            Guid   currentUserID = Guid.NewGuid();
            string currentUser   = "";

            #region Get current User
            MembershipUser membershipUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
            if (membershipUser != null)
            {
                currentUser   = membershipUser.UserName;
                currentUserID = (Guid)membershipUser.ProviderUserKey;
            }
            #endregion get current User
            xRPDataContext        dataContext      = new xRPDataContext();
            Qlvt_TinhChatNhapXuat tinhChatNhapXuat = new Qlvt_TinhChatNhapXuat();
            try
            {
                int?idd = int.Parse(id) == 0 || int.Parse(id) == -1 ? (int?)null : int.Parse(id);
                if (int.Parse(id) == -1)
                {
                    dataContext.Sp_Qlvt_DonViTinh_Add_Edit_Deli("ADD", null, tenTinhChat, 1, currentUserID, currentUserID, ref idd, Util.GetIP(), Util.GetPCName());
                }
                if (int.Parse(id) > 0)
                {
                    dataContext.Sp_Qlvt_DonViTinh_Add_Edit_Deli("EDIT", int.Parse(id), tenTinhChat, 1, currentUserID, currentUserID, ref idd, Util.GetIP(), Util.GetPCName());
                }
            }
            catch (Exception)
            {
                return("ERROR");
            }
            return("SUCCESS");
        }
Esempio n. 20
0
 public static string AddOrUpdateItem(int itemID, string maLoai, string tenLoai, string ghiChu)
 {
     try
     {
         //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace
         xRPDataContext dts = new xRPDataContext();
         //Get current user info
         var user = (from u in dts.aspnet_Users where u.UserName == HttpContext.Current.User.Identity.Name select u).FirstOrDefault();
         int?id   = null;
         if (itemID == 0 || itemID == -1)
         {
         }
         else
         {
             id = itemID;
         }
         Sp_Qlvt_LoaiVatTu_SelectResult current = null;
         if (id.HasValue)
         {
             current = dts.Sp_Qlvt_LoaiVatTu_Select(1, id.Value, "", null, null, "").FirstOrDefault();
         }
         string result = dts.Sp_Qlvt_LoaiVatTu_Add_Edit_Deli(!id.HasValue ? "ADD" : "EDIT", id, maLoai, tenLoai, "", ghiChu,
                                                             current == null || !current.KichHoat.HasValue ? 1 : (current.KichHoat.Value ? 1 : 0),
                                                             current != null ? current.MaNguoiTao : user.UserId, current != null ? user.UserId : (Guid?)null, ref id, "IP", "PC").FirstOrDefault().Column1;
         return(result != null && result != "" ? result : id.ToString());
     }
     catch (Exception ex)
     {
         return("ERROR: " + ex.Message + ex.StackTrace);
     }
 }
Esempio n. 21
0
        public static string UpdateKho(string id, string maKho, string tenKho, string diaChi, string sodienthoai, string nguoiphutrach, string kichHoat, string ghiChu, string thuocTongKho, string loaiKho)
        {
            try
            {
                int    thuoctongkho_temp = 0;
                Guid   currentUserID     = Guid.NewGuid();
                string currentUser       = "";
                #region Get current User
                MembershipUser membershipUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
                if (membershipUser != null)
                {
                    currentUser   = membershipUser.UserName;
                    currentUserID = (Guid)membershipUser.ProviderUserKey;
                }
                #endregion get current User
                xRPDataContext dataContext = new xRPDataContext();
                Qlvt_KhoVatTu  qlvt        = new Qlvt_KhoVatTu();
                int?           idd         = int.Parse(id) == 0 || int.Parse(id) == -1 ? (int?)null : int.Parse(id);

                if (int.Parse(id) == -1)
                {
                    dataContext.Sp_Qlvt_KhoVatTu_Add_Edit_Deli("ADD", 0, maKho, tenKho, thuoctongkho_temp, bool.Parse(loaiKho), diaChi, sodienthoai, nguoiphutrach, ghiChu, int.Parse(kichHoat), currentUserID, currentUserID, ref idd, Util.GetIP(), Util.GetPCName());
                }
                if (int.Parse(id) > 0)
                {
                    dataContext.Sp_Qlvt_KhoVatTu_Add_Edit_Deli("EDIT", int.Parse(id), maKho, tenKho, thuoctongkho_temp, bool.Parse(loaiKho), diaChi, sodienthoai, nguoiphutrach, ghiChu, int.Parse(kichHoat), currentUserID, currentUserID, ref idd, Util.GetIP(), Util.GetPCName());
                }
            }
            catch (Exception)
            {
                return("ERROR");
            }
            return("SUCCESS");
        }
Esempio n. 22
0
        public static CreateRoleStatus CreateRole(string name, string code, string note)
        {
            CreateRoleStatus status = new CreateRoleStatus();

            bool isExistName = false;
            bool isExistCode = false;

            xRPDataContext dataContext = new xRPDataContext();

            isExistName = dataContext.aspnet_Roles.FirstOrDefault(x => x.LoweredRoleName == name.ToLower()) != null;
            isExistCode = dataContext.aspnet_Roles.FirstOrDefault(x => x.Code.ToLower() == code.ToLower()) != null;

            status.IsDuplicateCode = isExistCode;
            status.IsDuplicateName = isExistName;

            try
            {
                if (!isExistCode && !isExistName)
                {
                    Roles.CreateRole(name);
                    aspnet_Role role = dataContext.aspnet_Roles.FirstOrDefault(x => x.LoweredRoleName == name.ToLower());
                    role.Code        = code;
                    role.Description = note;
                    //dataContext.aspnet_Roles.InsertOnSubmit(role);
                    dataContext.SubmitChanges();
                    status.IsSuccess = true;
                }
            }
            catch (Exception ex) { }

            return(status);
        }
Esempio n. 23
0
        public static string XoaSong(int id)
        {
            try
            {
                Guid   currentUserID = Guid.NewGuid();
                string currentUser   = "";
                #region Get current User
                MembershipUser membershipUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
                if (membershipUser != null)
                {
                    currentUser   = membershipUser.UserName;
                    currentUserID = (Guid)membershipUser.ProviderUserKey;
                }
                #endregion get current User
                //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace
                xRPDataContext dts = new xRPDataContext();

                var result = dts.Sp_Qldh_DanhMucSong_Deli("DEL1", id, currentUserID, Util.GetIP(), Util.GetPCName());
            }
            catch (Exception)
            {
                return("ERROR");
            }
            return("SUCCESS");
        }
Esempio n. 24
0
        public static string DeleteItem(int itemID)
        {
            xRPDataContext dataContext = new xRPDataContext();

            try
            {
                ////Initial data context variable, this class is declared in .dbml file in xRPDAL namespace
                //var dbContext = new xRPDataContext();
                //var delItem = dbContext.Qlvt_VatTus.FirstOrDefault(i => i.ID == itemID && (i.Xoa != null && !i.Xoa.Value));
                //if (delItem != null) //Check for item exists
                //{
                //    dbContext.Qlvt_VatTus.DeleteOnSubmit(delItem); //Call delete.
                //    dbContext.SubmitChanges(); // Submit change to data context.
                //}
                //dbContext.Dispose();

                Guid   currentUserID = Guid.NewGuid();
                string currentUser   = "";
                #region Get current User
                MembershipUser membershipUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
                if (membershipUser != null)
                {
                    currentUser   = membershipUser.UserName;
                    currentUserID = (Guid)membershipUser.ProviderUserKey;
                }
                #endregion get current User

                var result = dataContext.Sp_Qlvt_VatTu_Deli("DEL1", itemID, currentUserID, Util.GetIP(), Util.GetPCName());
            }
            catch (Exception)
            {
                return("ERROR");
            }
            return("SUCCESS");
        }
Esempio n. 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string URL = Attributes["param"];

            ID_KichThuoc = Util.GetParam(URL, "id");
            trang        = Util.GetParam(URL, "trang");

            if (ID_KichThuoc != "" && ID_KichThuoc != "-1")
            {
                int                id          = int.Parse(ID_KichThuoc);
                xRPDataContext     datacontext = new xRPDataContext();
                Qldh_LoaiKichThuoc qlkh        = (from c in datacontext.Qldh_LoaiKichThuocs where c.ID == id select c).FirstOrDefault();
                txtMaKichThuoc.Text  = qlkh.MaHieuKichThuoc;
                txtTenKichThuoc.Text = qlkh.LoaiKichThuoc;
                txtGhiChu.Text       = qlkh.GhiChu;
                txtHeSoChatDai.Text  = qlkh.HeSoChatDai.ToString();
                if (qlkh.KichHoat.Value == true)
                {
                    chkKichHoat.Checked = true;
                }
                if (qlkh.KichHoat.Value == false)
                {
                    chkKichHoat.Checked = false;
                }
            }
        }
Esempio n. 26
0
        public static string AddOrUpdateDonHang(int ID, int MaHieuKhachHang, string MaHieuDonHang,
                                                string NgayDatHang, string NgayGiaoHang, int TinhTrang, string GhiChu)
        {
            string returnMessage = "";

            try
            {
                DateTime       dtNgayDatHang  = DateTime.ParseExact(NgayDatHang, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                DateTime       dtNgayGiaoHang = DateTime.ParseExact(NgayGiaoHang, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                xRPDataContext dts            = new xRPDataContext();
                var            user           = (from u in dts.aspnet_Users where u.UserName == HttpContext.Current.User.Identity.Name select u).FirstOrDefault();
                int?           id             = ID;
                if (ID == 0)
                {
                    returnMessage = dts.Sp_Qldh_DonHang_Add_Edit_Deli("ADD", (int?)null, MaHieuKhachHang, dts.fc_SinhMa("MADONHANG", "*"), dtNgayDatHang, dtNgayGiaoHang, TinhTrang, GhiChu, "", user.UserId, user.UserId, ref id, Util.GetIP(), Util.GetPCName()).FirstOrDefault().Column1;
                }
                else
                {
                    returnMessage = dts.Sp_Qldh_DonHang_Add_Edit_Deli("EDIT", ID, MaHieuKhachHang, MaHieuDonHang, dtNgayDatHang, dtNgayGiaoHang, TinhTrang, GhiChu, "", user.UserId, user.UserId, ref id, Util.GetIP(), Util.GetPCName()).FirstOrDefault().Column1;
                }
                dts.Dispose();
                if (!string.IsNullOrEmpty(returnMessage))
                {
                    return(returnMessage);
                }
                return(id.HasValue ? id.Value.ToString() : "");
            }
            catch (Exception ex)
            {
                return("ERROR: " + ex.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var dts = new xRPDataContext();

            datepicker1.Value = DateTime.Now.ToString("dd/MM/yyyy");
            datepicker.Value  = DateTime.Now.AddMonths(-1).ToString("dd/MM/yyyy");
            BindGrid();
        }
Esempio n. 28
0
        public static string GetHangHoa(int IDDonHang)
        {
            List <xRPDAL.Sp_Qldh_MatHang_SelectResult> hh = new xRPDataContext().Sp_Qldh_MatHang_Select(2, (int?)null, IDDonHang, 0, (int?)null, "").ToList();

            hh = hh.OrderBy(t => t.NgayTao).ToList();
            string data = new JavaScriptSerializer().Serialize(hh);

            return(data);
        }
Esempio n. 29
0
        private void BindGrid()
        {
            var dts = new xRPDataContext();
            var x   = dts.Sp_Qlvt_VatTu_Select(0, null, null, null, null).ToList();

            colPage.DataSource             = x;
            colPage.BindToControl          = rptDanhMucLoaiVatTu;
            rptDanhMucLoaiVatTu.DataSource = colPage.DataSourcePaged;
        }
Esempio n. 30
0
        public static string AddOrUpdateVatTuNhap(int ID, int MaVatTu, int MaPhieuNhap, string DonViTinh, float DonGia,
                                                  float SoLuongThucNhap, float SoLuongDauCuon, float SoLuongLamPhieuNhap, float DinhLuongThucTe, float KichThuocThucTe,
                                                  float ChenhLechDinhLuong, float DinhLuongTinhTru, float TruThuaKichThuoc, float KhoiLuongTru, float TruLoi, float SoLuongChenhLechKhongTinh,
                                                  float ThanhTien, int?TinhTrang, float?KichThuocKiemTra, float?DinhLuongKiemTra, float?DoMucKiemTra, float?DoAmKiemTra, string CamQuanKiemTra, string GhiChu, string MaCuon
                                                  )
        {
            string sts = "";

            try
            {
                //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace
                xRPDataContext dts = new xRPDataContext();
                //Get current user info
                var user = (from u in dts.aspnet_Users where u.UserName == HttpContext.Current.User.Identity.Name select u).FirstOrDefault();

                Qlvt_VatTuNhap vtnhap = null;
                if (ID > 0)                                                                              //This item is existed
                {
                    vtnhap = (from t in dts.Qlvt_VatTuNhaps where t.ID == ID select t).FirstOrDefault(); //Get Item
                }
                bool flag      = false;
                int  donViTinh = (from t in dts.Qlvt_DonViTinhs where t.DonViTinh == DonViTinh select t).FirstOrDefault().ID;
                //int idVatTu = (from t in dts.Qlvt_VatTus where t.MaHieuVatTu == MaHieuVatTu select t).FirstOrDefault().ID;
                int idVatTu = MaVatTu;
                if (vtnhap == null) //Create new instance of LoaiVatTu
                {
                    int?   id = 0;
                    string x  = dts.Sp_Qlvt_VatTuNhap_Add_Edit_Deli("ADD", null, idVatTu
                                                                    , MaPhieuNhap, 1, donViTinh, DonGia,
                                                                    SoLuongThucNhap, SoLuongDauCuon, SoLuongLamPhieuNhap, DinhLuongThucTe, KichThuocThucTe, ChenhLechDinhLuong, DinhLuongTinhTru,
                                                                    TruThuaKichThuoc, KhoiLuongTru, TruLoi, SoLuongChenhLechKhongTinh, ThanhTien, GhiChu, user.UserId, user.UserId, TinhTrang, DinhLuongKiemTra, DoMucKiemTra, DoAmKiemTra, KichThuocKiemTra, CamQuanKiemTra, MaCuon, ref id, Util.GetIP(), Util.GetPCName()
                                                                    ).FirstOrDefault().Column1;

                    flag = true;
                    sts  = x == "null" ? "" : x;
                }

                if (vtnhap != null && !flag)
                {
                    int?id = 0;
                    // khương comment vì nỗi
                    string x = dts.Sp_Qlvt_VatTuNhap_Add_Edit_Deli("EDIT", ID, idVatTu,
                                                                   MaPhieuNhap, 1, donViTinh, DonGia,
                                                                   SoLuongThucNhap, SoLuongDauCuon, SoLuongLamPhieuNhap, DinhLuongThucTe, KichThuocThucTe, ChenhLechDinhLuong, DinhLuongTinhTru,
                                                                   TruThuaKichThuoc, KhoiLuongTru, TruLoi, SoLuongChenhLechKhongTinh, ThanhTien, GhiChu, null, user.UserId, TinhTrang, DinhLuongKiemTra, DoMucKiemTra, DoAmKiemTra, KichThuocKiemTra, CamQuanKiemTra, MaCuon, ref id, Util.GetIP(), Util.GetPCName()
                                                                   ).FirstOrDefault().Column1;

                    sts = x == "null" ? "" : x;
                }
            }
            catch (Exception ex)
            {
                return("ERROR: " + ex.StackTrace);
            }
            return(string.IsNullOrEmpty(sts) ? "SUCCESS" : sts);
        }