public static HOSOGOC findByHoSoGoc(string danhbo) { try { dbCallCenterDataContext db = new dbCallCenterDataContext(); var query = from q in db.HOSOGOCs where q.DBDongHoNuoc == danhbo orderby q.NgayCapNhat descending select q; return(query.First()); } catch (Exception ex) { } return(null); }
public static string IdentityBienNhan() { string loaihs = "CT"; string year = DateTime.Now.Year.ToString().Substring(2) + getMoth(); string kytumacdinh = year + loaihs; string id = kytumacdinh + "0001"; try { String_Indentity.String_Indentity obj = new String_Indentity.String_Indentity(); dbCallCenterDataContext db = new dbCallCenterDataContext(); db.Connection.Open(); string sql = " SELECT MAX(SoHoSo) as 'SoHoSo' FROM TiepNhan ORDER BY SoHoSo DESC"; SqlDataAdapter adapter = new SqlDataAdapter(sql, db.Connection.ConnectionString); DataTable table = new DataTable(); adapter.Fill(table); if (table.Rows.Count > 0) { if (table.Rows[0][0].ToString().Trim().Substring(0, 2).Equals(year.Substring(0, 2))) { int number = 1; id = obj.ID(kytumacdinh, table.Rows[0][0].ToString().Trim(), "0000", number) + ""; } else { id = obj.ID(year + loaihs, year + loaihs + "0000", "0000") + ""; } } else { id = obj.ID(kytumacdinh, table.Rows[0][0].ToString().Trim(), "0000") + ""; } db.Connection.Close(); } catch (Exception) { } return(id); }
public frmViewPdf(string danhbo) { InitializeComponent(); string varPathToNewLocation = AppDomain.CurrentDomain.BaseDirectory + @"\Test.pdf"; try { dbCallCenterDataContext db = new dbCallCenterDataContext(); if (db.Connection.State == ConnectionState.Open) { db.Connection.Close(); } db.Connection.Open(); SqlConnection sqlCon; sqlCon = new SqlConnection(db.Connection.ConnectionString); sqlCon.Open(); using (var sqlQuery = new SqlCommand(@"SELECT DataBlob FROM HOSOGOC WHERE DBDongHoNuoc='" + danhbo + "' ", sqlCon)) { using (var sqlQueryResult = sqlQuery.ExecuteReader()) if (sqlQueryResult != null) { sqlQueryResult.Read(); var blob = new Byte[(sqlQueryResult.GetBytes(0, 0, null, 0, int.MaxValue))]; sqlQueryResult.GetBytes(0, 0, blob, 0, blob.Length); using (var fs = new FileStream(varPathToNewLocation, FileMode.Create, FileAccess.Write)) fs.Write(blob, 0, blob.Length); } } sqlCon.Close(); string local = varPathToNewLocation.Replace(@"\\", @"\"); //MessageBox.Show(this, local); axAcroPDF2.LoadFile(local); } catch (Exception Ex) { MessageBox.Show(this, "Lỗi "); } }
public void Refresh() { _db = new dbCallCenterDataContext(); }