public static bool Connection_Test(ENTITE.Serveur bean) { if (bean.Control_()) { NpgsqlConnection con = new NpgsqlConnection(); try { string constr = "PORT=" + bean.getPort + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;DATABASE=" + bean.getDatabase + ";HOST=" + bean.getAdresse + ";PASSWORD="******";USER ID=" + bean.getUser + ""; con = new NpgsqlConnection(constr); con.Open(); return true; } catch (NpgsqlException ex) { Messages.Exception(ex); return false; } finally { con.Close(); con.Dispose(); } } return false; }
private static NpgsqlConnection getConnexion(ENTITE.Serveur bean) { try { if (bean.Control_()) { NpgsqlConnection con = isConnection(bean); con.Open(); return con; } else { if (DialogResult.Retry == Messages.Erreur_Retry("Connexion impossible ! Entrer de nouveaux parametres")) { new IHM.Form_Serveur().Show(); } } } catch (NpgsqlException ex) { Messages.Exception(ex); } return null; }
private static String ReferenceElement(ENTITE.ModelReference modele) { if ((modele != null) ? modele.Id > 0 : false) { String reference = ""; String apercu = modele.Prefix + modele.Separateur; if (modele.Jour) { if ((int)DateTime.Now.Day > 9) { apercu += (int)DateTime.Now.Day; } if ((int)DateTime.Now.Day < 10) { apercu += ("0" + (int)DateTime.Now.Day); } } if (modele.Mois) { if ((int)DateTime.Now.Month > 9) { apercu += (int)DateTime.Now.Month; } if ((int)DateTime.Now.Month < 10) { apercu += ("0" + (int)DateTime.Now.Month); } } if (modele.Annee) { apercu += DateTime.Now.Year.ToString().Substring(2); } apercu += modele.Separateur; switch (modele.Element.Designation) { case Constantes.DOC_COMMANDE: case Constantes.DOC_FACTURE: Facture f = FactureBll.One_(apercu + "%"); if ((f != null) ? f.Id > 0 : false) { reference = f.NumDoc; } else { reference = ""; } break; case Constantes.DOC_PIECE: break; default: return ""; } if (!reference.Trim().Equals("")) { String partieNum = reference.Replace(apercu, ""); if (apercu.Equals(reference.Replace(partieNum, ""))) { int num = Convert.ToInt16(partieNum); if (Convert.ToString(num + 1).Length > modele.Taille) { Messages.ShowErreur("Vous ne pouvez plus ajouter ce type de document"); return ""; } else { for (int i = 0; i < (modele.Taille - Convert.ToString(num + 1).Length); i++) { apercu += "0"; } } apercu += Convert.ToString(Convert.ToInt16(partieNum) + 1); } else { for (int i = 0; i < modele.Taille; i++) { apercu += "0"; } } } else { for (int i = 0; i < modele.Taille; i++) { apercu += "0"; } } return apercu; } else { TOOLS.Messages.ShowErreur("Le model de reference n'existe pas!"); } return null; }
private static NpgsqlConnection isConnection(ENTITE.Serveur bean) { try { string constr = "PORT=" + bean.getPort + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;DATABASE=" + bean.getDatabase + ";HOST=" + bean.getAdresse + ";PASSWORD="******";USER ID=" + bean.getUser + ""; return new NpgsqlConnection(constr); } catch (Exception ex) { Messages.Exception(ex); } return null; }