Ejemplo n.º 1
0
 public string AddGroupContacts(ContactsSummary obj)
 {
     try
     {
         U_USR_Map_Usr_To_ContactDAL ocontactsDAL = new U_USR_Map_Usr_To_ContactDAL();
         U_USR_Map_Usr_To_Contact    ocnts        = new U_USR_Map_Usr_To_Contact();
         foreach (var items in obj.UserContacts)
         {
             if (string.IsNullOrEmpty(ocontactsDAL.IsGroupContact_Exist(obj.groupId, items.UserId)))
             {
                 ocnts.UsrMap_Seq_Id = Guid.NewGuid().ToString();
                 ocnts.Usr_Id        = obj.createrId;
                 ocnts.Contact_Id    = items.UserId;
                 ocnts.Group_Id      = obj.groupId;
                 ocnts.Comments      = "";
                 ocnts.Created_by    = "";
                 ocnts.Created_Date  = DateTime.Now;
                 ocnts.Updated_by    = "";
                 ocnts.Updated_Date  = DateTime.Now;
                 ocontactsDAL.InsertU_USR_Map_Usr_To_Contact(ocnts);
             }
         }
         return("1"); // 1 successfull
     }
     catch (Exception ex)
     {
         Console.Write(ex);
         return("0"); // 0 indicates unsuccessfull
     }
 }
Ejemplo n.º 2
0
 private void SetParameters(SqlParameter[] U_USR_Map_Usr_To_ContactParms, U_USR_Map_Usr_To_Contact tobjU_USR_Map_Usr_To_Contact)
 {
     U_USR_Map_Usr_To_ContactParms[0].Value = tobjU_USR_Map_Usr_To_Contact.UsrMap_Seq_Id;
     U_USR_Map_Usr_To_ContactParms[1].Value = tobjU_USR_Map_Usr_To_Contact.Usr_Id;
     U_USR_Map_Usr_To_ContactParms[2].Value = tobjU_USR_Map_Usr_To_Contact.Contact_Id;
     U_USR_Map_Usr_To_ContactParms[3].Value = tobjU_USR_Map_Usr_To_Contact.Group_Id;
     U_USR_Map_Usr_To_ContactParms[4].Value = tobjU_USR_Map_Usr_To_Contact.Comments;
     U_USR_Map_Usr_To_ContactParms[5].Value = tobjU_USR_Map_Usr_To_Contact.Created_Date;
     U_USR_Map_Usr_To_ContactParms[6].Value = tobjU_USR_Map_Usr_To_Contact.Updated_Date;
     U_USR_Map_Usr_To_ContactParms[7].Value = tobjU_USR_Map_Usr_To_Contact.Created_by;
     U_USR_Map_Usr_To_ContactParms[8].Value = tobjU_USR_Map_Usr_To_Contact.Updated_by;
 }
Ejemplo n.º 3
0
 public bool InsertU_USR_Map_Usr_To_Contact(U_USR_Map_Usr_To_Contact tobjU_USR_Map_Usr_To_Contact)
 {
     if (tobjU_USR_Map_Usr_To_Contact != null)
     {
         //Get the parameter list needed by the given object
         SqlParameter[] lParamArray = GetParameters(tobjU_USR_Map_Usr_To_Contact);
         SetParameters(lParamArray, tobjU_USR_Map_Usr_To_Contact);
         //Get the connection
         SqlConnection con = General.GetConnection();
         if (con == null)
         {
             //Connection is not created
             return(false);
         }
         //Execute the insertion
         int i = SqlHelper.ExecuteNonQuery(
             con,
             CommandType.Text,
             SQL_INSERT_U_USR_Map_Usr_To_Contact,
             lParamArray);
         //Dispose the Sql connection
         con.Dispose();
         if (i == 1)
         {
             //Done and insert the object to the table
             return(true);
         }
         else
         {
             //Fail to execute the insertion
             return(false);
         }
     }
     else
     {
         //No object found to insert
         return(false);
     }
 }
Ejemplo n.º 4
0
 private SqlParameter[] GetParameters(U_USR_Map_Usr_To_Contact tobjU_USR_Map_Usr_To_Contact)
 {
     SqlParameter[] objParamArray = SqlHelperParameterCache.GetCachedParameterSet(General.SQL_CONN_STRING, SQL_INSERT_U_USR_Map_Usr_To_Contact);
     if (objParamArray == null)
     {
         //Represents a parameter to a System.Data.SqlClient.SqlCommand,
         //and optionally, its mapping to System.Data.DataSet columns.
         objParamArray = new SqlParameter[]
         {
             new SqlParameter(PARAM_UsrMap_Seq_Id, tobjU_USR_Map_Usr_To_Contact.UsrMap_Seq_Id),
             new SqlParameter(PARAM_Usr_Id, tobjU_USR_Map_Usr_To_Contact.Usr_Id),
             new SqlParameter(PARAM_Contact_Id, tobjU_USR_Map_Usr_To_Contact.Contact_Id),
             new SqlParameter(PARAM_Group_Id, tobjU_USR_Map_Usr_To_Contact.Group_Id),
             new SqlParameter(PARAM_Comments, tobjU_USR_Map_Usr_To_Contact.Comments),
             new SqlParameter(PARAM_Created_Date, tobjU_USR_Map_Usr_To_Contact.Created_Date),
             new SqlParameter(PARAM_Updated_Date, tobjU_USR_Map_Usr_To_Contact.Updated_Date),
             new SqlParameter(PARAM_Created_by, tobjU_USR_Map_Usr_To_Contact.Created_by),
             new SqlParameter(PARAM_Updated_by, tobjU_USR_Map_Usr_To_Contact.Updated_by),
         };
         SqlHelperParameterCache.CacheParameterSet(General.SQL_CONN_STRING, SQL_INSERT_U_USR_Map_Usr_To_Contact, objParamArray);
     }
     return(objParamArray);
 }