public virtual void Remove(int id) { try { CONG_NO_CK b = this.GetById(id); this.Remove(b); } catch (Exception e) { throw new Exception(e.Message); } }
public virtual void Remove(CONG_NO_CK b) { try { db.CONG_NO_CKs.DeleteOnSubmit(b); db.SubmitChanges(); } catch (Exception e) { throw new Exception(e.Message); } }
public virtual void Create(CONG_NO_CK cus) { try { this.db.CONG_NO_CKs.InsertOnSubmit(cus); db.SubmitChanges(); } catch //(Exception e) { //throw new Exception(e.Message); } }
public virtual void Update(CONG_NO_CK cus) { try { CONG_NO_CK cusOld = this.GetById(cus.ID); cusOld = cus; db.SubmitChanges(); } catch //(Exception e) { //throw new Exception(e.Message); } }
private int Save_Data() { if (id != 0) { var i = proj_data.GetById(id); i.STT = Utils.CIntDef(txtSTT.Text); i.TEN_CTY = txtTenKH.Text; i.MST = txtMST.Text; i.NGAY_NHAN_TB = txtNgayNhanTB.Text != "" ? DateTime.ParseExact(txtNgayNhanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.NGAY_NHAN_TB = null; i.NV_KD = Utils.CIntDef(ddlNVKD.SelectedValue); i.TINH_TRANG = ddlTinhTrang.Text; i.LOAI_HOPDONG = ddlLoaiHD.Text; #region CKS i.CKS_NHA_CUNG_CAP = ddlNhaCungCap.SelectedValue; i.CKS_SAN_PHAM = ddlSanPham.SelectedValue; i.CKS_PHI_DV = Utils.CIntDef(txtCKS_PhiDV.Text.Replace(",", "")); i.CKS_GIA_TK = Utils.CIntDef(txtCKS_GiaTbToken.Text.Replace(",", "")); i.CKS_VAT = Utils.CIntDef(txtCKS_VAT.Text.Replace(",", "")); i.CKS_TONG_CONG = Utils.CIntDef(txtCKS_TongCong.Text.Replace(",", "")); i.CKS_HOA_HONG_TL = Utils.CIntDef(txtCKS_HoaHong_TyLe.Text.Replace(",", "")); i.CKS_HOA_HONG_DL = Utils.CIntDef(txtCKS_HoaHong_DL.Text.Replace(",", "")); i.CKS_HOA_HONG_VAT = Utils.CIntDef(txtCKS_HoaHong_VAT.Text.Replace(",", "")); i.CKS_HOA_HONG = Utils.CIntDef(txtCKS_HoaHong.Text.Replace(",", "")); i.CKS_TONG_TT_NCC = Utils.CIntDef(txtCKS_TongTTNhaCC.Text.Replace(",", "")); i.CKS_NGAY_HH_TB = txtNgayHetHanTB.Text != "" ? DateTime.ParseExact(txtNgayHetHanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.CKS_NGAY_HH_TB = null; #endregion #region PM i.PM_NHA_CUNG_CAP = ddlNhaCungCap1.SelectedValue; i.PM_SAN_PHAM = ddlSanPham1.SelectedValue; i.PM_PHI_DV = Utils.CIntDef(txtPM_PhiDV.Text.Replace(",", "")); i.PM_GIA_TK = Utils.CIntDef(txtPM_GiaTbToken.Text.Replace(",", "")); i.PM_VAT = Utils.CIntDef(txtPM_VAT.Text.Replace(",", "")); i.PM_TONG_CONG = Utils.CIntDef(txtPM_TongCong.Text.Replace(",", "")); i.PM_HOA_HONG_TL = Utils.CIntDef(txtPM_HoaHong_TyLe.Text.Replace(",", "")); i.PM_HOA_HONG_DL = Utils.CIntDef(txtPM_HoaHong_DL.Text.Replace(",", "")); i.PM_HOA_HONG_VAT = Utils.CIntDef(txtPM_HoaHong_VAT.Text.Replace(",", "")); i.PM_HOA_HONG = Utils.CIntDef(txtPM_HoaHong.Text.Replace(",", "")); i.PM_TONG_TT_NCC = Utils.CIntDef(txtPM_TongTTNhaCC.Text.Replace(",", "")); i.PM_NGAY_HH_TB = txtNgayHetHanTB1.Text != "" ? DateTime.ParseExact(txtNgayHetHanTB1.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.PM_NGAY_HH_TB = null; #endregion i.TT_TK_CKS = Utils.CIntDef(txtTT_TokenCKS.Text.Replace(",", "")); i.TT_PHAN_MEM = Utils.CIntDef(txtTT_PM.Text.Replace(",", "")); i.TT_HH_CKS = Utils.CIntDef(txtTTHoaHong_CKS.Text.Replace(",", "")); i.TT_HH_PM = Utils.CIntDef(txtTTHoaHong_PM.Text.Replace(",", "")); i.CON_NO = Utils.CIntDef(txtTT_ConNo.Text.Replace(",", "")); i.NGAY_THU = txtTT_NgayThu.Text; i.GHI_CHU = txtGhiChu.Text; proj_data.Update(i); db.SubmitChanges(); } else { CONG_NO_CK i = new CONG_NO_CK(); i.STT = Utils.CIntDef(txtSTT.Text); i.TEN_CTY = txtTenKH.Text; i.MST = txtMST.Text; i.NGAY_NHAN_TB = txtNgayNhanTB.Text != "" ? DateTime.ParseExact(txtNgayNhanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.NGAY_NHAN_TB = null; i.NV_KD = Utils.CIntDef(ddlNVKD.SelectedValue); i.TINH_TRANG = ddlTinhTrang.Text; i.LOAI_HOPDONG = ddlLoaiHD.Text; #region CKS i.CKS_NHA_CUNG_CAP = ddlNhaCungCap.SelectedValue; i.CKS_SAN_PHAM = ddlSanPham.SelectedValue; i.CKS_PHI_DV = Utils.CIntDef(txtCKS_PhiDV.Text.Replace(",", "")); i.CKS_GIA_TK = Utils.CIntDef(txtCKS_GiaTbToken.Text.Replace(",", "")); i.CKS_VAT = Utils.CIntDef(txtCKS_VAT.Text.Replace(",", "")); i.CKS_TONG_CONG = Utils.CIntDef(txtCKS_TongCong.Text.Replace(",", "")); i.CKS_HOA_HONG_TL = Utils.CIntDef(txtCKS_HoaHong_TyLe.Text.Replace(",", "")); i.CKS_HOA_HONG_DL = Utils.CIntDef(txtCKS_HoaHong_DL.Text.Replace(",", "")); i.CKS_HOA_HONG_VAT = Utils.CIntDef(txtCKS_HoaHong_VAT.Text.Replace(",", "")); i.CKS_HOA_HONG = Utils.CIntDef(txtCKS_HoaHong.Text.Replace(",", "")); i.CKS_TONG_TT_NCC = Utils.CIntDef(txtCKS_TongTTNhaCC.Text.Replace(",", "")); i.CKS_NGAY_HH_TB = txtNgayHetHanTB.Text != "" ? DateTime.ParseExact(txtNgayHetHanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.CKS_NGAY_HH_TB = null; #endregion #region PM i.PM_NHA_CUNG_CAP = ddlNhaCungCap1.SelectedValue; i.PM_SAN_PHAM = ddlSanPham1.SelectedValue; i.PM_PHI_DV = Utils.CIntDef(txtPM_PhiDV.Text.Replace(",", "")); i.PM_GIA_TK = Utils.CIntDef(txtPM_GiaTbToken.Text.Replace(",", "")); i.PM_VAT = Utils.CIntDef(txtPM_VAT.Text.Replace(",", "")); i.PM_TONG_CONG = Utils.CIntDef(txtPM_TongCong.Text.Replace(",", "")); i.PM_HOA_HONG_TL = Utils.CIntDef(txtPM_HoaHong_TyLe.Text.Replace(",", "")); i.PM_HOA_HONG_DL = Utils.CIntDef(txtPM_HoaHong_DL.Text.Replace(",", "")); i.PM_HOA_HONG_VAT = Utils.CIntDef(txtPM_HoaHong_VAT.Text.Replace(",", "")); i.PM_HOA_HONG = Utils.CIntDef(txtPM_HoaHong.Text.Replace(",", "")); i.PM_TONG_TT_NCC = Utils.CIntDef(txtPM_TongTTNhaCC.Text.Replace(",", "")); i.PM_NGAY_HH_TB = txtNgayHetHanTB.Text != "" ? DateTime.ParseExact(txtNgayHetHanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.PM_NGAY_HH_TB = null; #endregion i.TT_TK_CKS = Utils.CIntDef(txtTT_TokenCKS.Text.Replace(",", "")); i.TT_PHAN_MEM = Utils.CIntDef(txtTT_PM.Text.Replace(",", "")); i.TT_HH_CKS = Utils.CIntDef(txtTTHoaHong_CKS.Text.Replace(",", "")); i.TT_HH_PM = Utils.CIntDef(txtTTHoaHong_PM.Text.Replace(",", "")); i.CON_NO = Utils.CIntDef(txtTT_ConNo.Text.Replace(",", "")); i.NGAY_THU = txtTT_NgayThu.Text; i.GHI_CHU = txtGhiChu.Text; proj_data.Create(i); var getlink = db.CONG_NO_CKs.OrderByDescending(n => n.ID).Take(1).ToList(); if (getlink.Count > 0) { id = Utils.CIntDef(getlink[0].ID); return 1; } } return 0; }
private void Import_data() { try { if (fileUpload.HasFile == true) { string path = Server.MapPath("/File/ExcelFile/" + fileUpload.FileName); fileUpload.SaveAs(path); DataTable dt = getDataexcel(path); int i = 0; foreach (DataRow row in dt.Rows) { CONG_NO_CK obj = new CONG_NO_CK(); obj.STT = Utils.CIntDef(row[0].ToString().Trim()); obj.TEN_CTY = row[1].ToString().Trim(); obj.MST = row[2].ToString().Trim(); obj.NV_KD = null; obj.NGAY_NHAN_TB = DateTime.ParseExact(row[3].ToString().Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); obj.CKS_NHA_CUNG_CAP = row[6].ToString().Trim(); obj.CKS_SAN_PHAM = row[9].ToString().Trim(); obj.CKS_PHI_DV = Utils.CIntDef(row[14].ToString().Replace(".", "")); obj.CKS_GIA_TK = Utils.CIntDef(row[15].ToString().Replace(".", "")); obj.CKS_VAT = Utils.CIntDef(row[16].ToString().Replace(".", "")); obj.CKS_TONG_CONG = Utils.CIntDef(row[17].ToString().Replace(".", "")); obj.CKS_HOA_HONG = Utils.CIntDef(row[23].ToString().Replace(".", "")); obj.CKS_TONG_TT_NCC = Utils.CIntDef(row[24].ToString().Replace(".", "")); obj.TT_TK_CKS = Utils.CIntDef(row[34].ToString().Replace(".", "")); obj.TT_PHAN_MEM = Utils.CIntDef(row[35].ToString().Replace(".", "")); obj.TT_HH_CKS = Utils.CIntDef(row[36].ToString().Replace(".", "")); obj.TT_HH_PM = Utils.CIntDef(row[37].ToString().Replace(".", "")); obj.CON_NO = Utils.CIntDef(row[38].ToString().Replace(".", "")); obj.NGAY_THU = row[40].ToString().Trim(); obj.GHI_CHU = row[41].ToString().Trim(); obj.THANG = ddlThang.SelectedValue; obj.NAM = ddlNam.SelectedValue; _CongNoCKSData.Create(obj); i++; } string strScript = "<script>"; strScript += "alert('Đã Import dữ liệu thành công');"; strScript += "window.location='danh-sach-cong-no-cks.aspx';"; strScript += "</script>"; Page.RegisterClientScriptBlock("strScript", strScript); } else { string strScript = "<script>"; strScript += "alert('Xin chọn file để Import');"; strScript += "window.location='danh-sach-cong-no-cks.aspx';"; strScript += "</script>"; Page.RegisterClientScriptBlock("strScript", strScript); } } catch (Exception ex) { throw; } }
private int Save_Data() { if (id != 0) { var i = proj_data.GetById(id); i.STT = Utils.CIntDef(txtSTT.Text); i.TEN_CTY = txtTenKH.Text; i.MST = txtMST.Text; i.NGAY_NHAN_TB = txtNgayNhanTB.Text != "" ? DateTime.ParseExact(txtNgayNhanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.NGAY_NHAN_TB = null; i.NV_KD = Utils.CIntDef(ddlNVKD.SelectedValue); i.TINH_TRANG = ddlTinhTrang.Text; i.LOAI_HOPDONG = ddlLoaiHD.Text; #region CKS i.CKS_NHA_CUNG_CAP = ddlNhaCungCap.SelectedValue; i.CKS_SAN_PHAM = ddlSanPham.SelectedValue; i.CKS_PHI_DV = Utils.CIntDef(txtCKS_PhiDV.Text.Replace(",", "")); i.CKS_GIA_TK = Utils.CIntDef(txtCKS_GiaTbToken.Text.Replace(",", "")); i.CKS_VAT = Utils.CIntDef(txtCKS_VAT.Text.Replace(",", "")); i.CKS_TONG_CONG = Utils.CIntDef(txtCKS_TongCong.Text.Replace(",", "")); i.CKS_HOA_HONG_TL = Utils.CIntDef(txtCKS_HoaHong_TyLe.Text.Replace(",", "")); i.CKS_HOA_HONG_DL = Utils.CIntDef(txtCKS_HoaHong_DL.Text.Replace(",", "")); i.CKS_HOA_HONG_VAT = Utils.CIntDef(txtCKS_HoaHong_VAT.Text.Replace(",", "")); i.CKS_HOA_HONG = Utils.CIntDef(txtCKS_HoaHong.Text.Replace(",", "")); i.CKS_TONG_TT_NCC = Utils.CIntDef(txtCKS_TongTTNhaCC.Text.Replace(",", "")); i.CKS_NGAY_HH_TB = txtNgayHetHanTB.Text != "" ? DateTime.ParseExact(txtNgayHetHanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.CKS_NGAY_HH_TB = null; #endregion #region PM i.PM_NHA_CUNG_CAP = ddlNhaCungCap1.SelectedValue; i.PM_SAN_PHAM = ddlSanPham1.SelectedValue; i.PM_PHI_DV = Utils.CIntDef(txtPM_PhiDV.Text.Replace(",", "")); i.PM_GIA_TK = Utils.CIntDef(txtPM_GiaTbToken.Text.Replace(",", "")); i.PM_VAT = Utils.CIntDef(txtPM_VAT.Text.Replace(",", "")); i.PM_TONG_CONG = Utils.CIntDef(txtPM_TongCong.Text.Replace(",", "")); i.PM_HOA_HONG_TL = Utils.CIntDef(txtPM_HoaHong_TyLe.Text.Replace(",", "")); i.PM_HOA_HONG_DL = Utils.CIntDef(txtPM_HoaHong_DL.Text.Replace(",", "")); i.PM_HOA_HONG_VAT = Utils.CIntDef(txtPM_HoaHong_VAT.Text.Replace(",", "")); i.PM_HOA_HONG = Utils.CIntDef(txtPM_HoaHong.Text.Replace(",", "")); i.PM_TONG_TT_NCC = Utils.CIntDef(txtPM_TongTTNhaCC.Text.Replace(",", "")); i.PM_NGAY_HH_TB = txtNgayHetHanTB1.Text != "" ? DateTime.ParseExact(txtNgayHetHanTB1.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.PM_NGAY_HH_TB = null; #endregion i.TT_TK_CKS = Utils.CIntDef(txtTT_TokenCKS.Text.Replace(",", "")); i.TT_PHAN_MEM = Utils.CIntDef(txtTT_PM.Text.Replace(",", "")); i.TT_HH_CKS = Utils.CIntDef(txtTTHoaHong_CKS.Text.Replace(",", "")); i.TT_HH_PM = Utils.CIntDef(txtTTHoaHong_PM.Text.Replace(",", "")); i.CON_NO = Utils.CIntDef(txtTT_ConNo.Text.Replace(",", "")); i.NGAY_THU = txtTT_NgayThu.Text; i.GHI_CHU = txtGhiChu.Text; proj_data.Update(i); db.SubmitChanges(); } else { CONG_NO_CK i = new CONG_NO_CK(); i.STT = Utils.CIntDef(txtSTT.Text); i.TEN_CTY = txtTenKH.Text; i.MST = txtMST.Text; i.NGAY_NHAN_TB = txtNgayNhanTB.Text != "" ? DateTime.ParseExact(txtNgayNhanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.NGAY_NHAN_TB = null; i.NV_KD = Utils.CIntDef(ddlNVKD.SelectedValue); i.TINH_TRANG = ddlTinhTrang.Text; i.LOAI_HOPDONG = ddlLoaiHD.Text; #region CKS i.CKS_NHA_CUNG_CAP = ddlNhaCungCap.SelectedValue; i.CKS_SAN_PHAM = ddlSanPham.SelectedValue; i.CKS_PHI_DV = Utils.CIntDef(txtCKS_PhiDV.Text.Replace(",", "")); i.CKS_GIA_TK = Utils.CIntDef(txtCKS_GiaTbToken.Text.Replace(",", "")); i.CKS_VAT = Utils.CIntDef(txtCKS_VAT.Text.Replace(",", "")); i.CKS_TONG_CONG = Utils.CIntDef(txtCKS_TongCong.Text.Replace(",", "")); i.CKS_HOA_HONG_TL = Utils.CIntDef(txtCKS_HoaHong_TyLe.Text.Replace(",", "")); i.CKS_HOA_HONG_DL = Utils.CIntDef(txtCKS_HoaHong_DL.Text.Replace(",", "")); i.CKS_HOA_HONG_VAT = Utils.CIntDef(txtCKS_HoaHong_VAT.Text.Replace(",", "")); i.CKS_HOA_HONG = Utils.CIntDef(txtCKS_HoaHong.Text.Replace(",", "")); i.CKS_TONG_TT_NCC = Utils.CIntDef(txtCKS_TongTTNhaCC.Text.Replace(",", "")); i.CKS_NGAY_HH_TB = txtNgayHetHanTB.Text != "" ? DateTime.ParseExact(txtNgayHetHanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.CKS_NGAY_HH_TB = null; #endregion #region PM i.PM_NHA_CUNG_CAP = ddlNhaCungCap1.SelectedValue; i.PM_SAN_PHAM = ddlSanPham1.SelectedValue; i.PM_PHI_DV = Utils.CIntDef(txtPM_PhiDV.Text.Replace(",", "")); i.PM_GIA_TK = Utils.CIntDef(txtPM_GiaTbToken.Text.Replace(",", "")); i.PM_VAT = Utils.CIntDef(txtPM_VAT.Text.Replace(",", "")); i.PM_TONG_CONG = Utils.CIntDef(txtPM_TongCong.Text.Replace(",", "")); i.PM_HOA_HONG_TL = Utils.CIntDef(txtPM_HoaHong_TyLe.Text.Replace(",", "")); i.PM_HOA_HONG_DL = Utils.CIntDef(txtPM_HoaHong_DL.Text.Replace(",", "")); i.PM_HOA_HONG_VAT = Utils.CIntDef(txtPM_HoaHong_VAT.Text.Replace(",", "")); i.PM_HOA_HONG = Utils.CIntDef(txtPM_HoaHong.Text.Replace(",", "")); i.PM_TONG_TT_NCC = Utils.CIntDef(txtPM_TongTTNhaCC.Text.Replace(",", "")); i.PM_NGAY_HH_TB = txtNgayHetHanTB.Text != "" ? DateTime.ParseExact(txtNgayHetHanTB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture) : i.PM_NGAY_HH_TB = null; #endregion i.TT_TK_CKS = Utils.CIntDef(txtTT_TokenCKS.Text.Replace(",", "")); i.TT_PHAN_MEM = Utils.CIntDef(txtTT_PM.Text.Replace(",", "")); i.TT_HH_CKS = Utils.CIntDef(txtTTHoaHong_CKS.Text.Replace(",", "")); i.TT_HH_PM = Utils.CIntDef(txtTTHoaHong_PM.Text.Replace(",", "")); i.CON_NO = Utils.CIntDef(txtTT_ConNo.Text.Replace(",", "")); i.NGAY_THU = txtTT_NgayThu.Text; i.GHI_CHU = txtGhiChu.Text; proj_data.Create(i); var getlink = db.CONG_NO_CKs.OrderByDescending(n => n.ID).Take(1).ToList(); if (getlink.Count > 0) { id = Utils.CIntDef(getlink[0].ID); return(1); } } return(0); }