/// <remarks>
 /// adds new entry to Contacts table
 /// </remarks>
 /// <param name="customerID"></param>
 /// <param name="contactTypeID"></param>
 /// <param name="value"></param>
 /// <param name="created"></param>
 public void addNew (int customerID, int contactTypeID, string value, DateTime created)
 {
     _log.Trace("in addNew()");
     using (Keskus_baasEntities db = new Keskus_baasEntities())
     {
         DAL.Contact contact = new DAL.Contact
         {
             CustomerID = customerID,
             ContactTypeID = contactTypeID,
             Value = value,
             Created = created
         };
         db.Contacts.Add(contact);
        
         try
         {
             db.SaveChanges();
             _userlog.Trace(string.Format("Contact was added on {0} for customer {1}: type {2} - value {3}", contact.Created, contact.CustomerID, contact.ContactTypeID, contact.Value ));
         }
         catch (Exception ex)
         {
             _log.Trace(string.Format("addNew() - An error occurred: '{0}'", ex));
         }
     }
 }
Пример #2
0
        public void bindGridviews(Guid UserId)
        {
            //get grid emovement
            DAL.EmployeeMovement emov = new DAL.EmployeeMovement();
            gvEMovement.DataSource = emov.DisplayEMovement(UserId);
            gvEMovement.DataBind();

            //get grid jobexp
            DAL.Experience exp = new DAL.Experience();
            gvExperience.DataSource = exp.getExperienceById(UserId);
            gvExperience.DataBind();

            //get grid education
            DAL.Education educ = new DAL.Education();
            gvEducation.DataSource = educ.getEducationById(UserId);
            gvEducation.DataBind();

            //get grid trainings
            DAL.Training training = new DAL.Training();
            gvTrainings.DataSource = training.getTrainingsById(UserId);
            gvTrainings.DataBind();

            //get grid awards
            DAL.Award award = new DAL.Award();
            gvAwards.DataSource = award.getAwardsById(UserId);
            gvAwards.DataBind();

            //get grid violation
            DAL.Violation violation = new DAL.Violation();
            gvViolations.DataSource = violation.getViolationsById(UserId);
            gvViolations.DataBind();

            //get grid foremergency
            DAL.Contact contact = new DAL.Contact();
            gvForEmergency.DataSource = contact.getContactById(UserId);
            gvForEmergency.DataBind();

            //get grid personalcards
            DAL.MembershipCard memCard = new DAL.MembershipCard();
            gvPersonalCards.DataSource = memCard.getPersonalCardsById(UserId);
            gvPersonalCards.DataBind();

            BindDocuments(UserId);
        }
Пример #3
0
        //Exact Name of the Contact
        public DAL.Contact GetContact(string namequery)
        {
            _contacts = GetAllContacts();
            DAL.Contact contact = new DAL.Contact();

            return _contacts.Count > 0 ? _contacts.SingleOrDefault(x => x.ContactName.ToLower().Equals(namequery)) : null;
        }
Пример #4
0
        //by Department
        public List<DAL.Contact> GetAllContactsByDepartements(string departementhquery)
        {
            _contacts = new List<DAL.Contact>();
            //string query = "SELECT * FROM tb_CONTACT";
            //Retrieving data using stored procedure that we created in the DB
            string query = "SP_GET_CONTACTS_BY_DEPT";

            try
            {

                SqlCommand readcommand = new SqlCommand();
                readcommand.CommandText = query;
                readcommand.Connection = MyConnection;
                readcommand.CommandType = CommandType.StoredProcedure;
                readcommand.Parameters.AddWithValue("@department", departementhquery);
                MyConnection.Open();

                SqlDataReader reader = readcommand.ExecuteReader();
                while (reader.Read())
                {
                    var aContact = new DAL.Contact
                    {
                        ContactName = reader["ContactName"].ToString(),
                        ContactPhone = reader["Telephone"].ToString(),
                        ContactEmail = reader["Email_Address"].ToString(),
                        ContactTag = reader["ContactTag"].ToString(),
                        ContactLocation = reader["ContactLocation"].ToString(),
                    };

                    string strContactId = reader["ContactId"].ToString().Trim().ToUpper();
                    if (!string.IsNullOrEmpty(strContactId))
                    {
                        aContact.ContactId = new Guid(strContactId);
                    }

                    string strDeptId = reader["Dpt_ID"].ToString().Trim().ToUpper();
                    if (!string.IsNullOrEmpty(strDeptId))
                    {
                        aContact.ContactDeptId = new Guid(strDeptId);
                    }

                    string strUserId = reader["UserID"].ToString().Trim().ToUpper();
                    if (!string.IsNullOrEmpty(strUserId))
                    {
                        aContact.ContactUserId = new Guid(strUserId);
                    }

                    string strContactPhototId =
                           reader["ContactPhotoId"].ToString().Trim().ToUpper();
                    if (!string.IsNullOrEmpty(strContactPhototId))
                    {
                        aContact.ContactPhotoId = new Guid(strContactPhototId);
                    }
                    _contacts.Add(aContact);
                }

                _resultMessage = "Success";
            }

            catch (Exception sqlException)
            {
                //for testing purpose
                SqlRelatedErroMessage = sqlException.Message;
            }

            MyConnection.Close();

            return _contacts;

            /* THIS CODE SEGMENT HAS BEEN DEPRECIATED NOW WE ARE USING STORED PROCEDURES WHICH RESIDES INSIDE THE DATABASE TO PERFORM CRUD OPERATIONS */
            //_contacts = GetAllContacts();
            //departementhquery = departementhquery.ToLower();

            //var contactByDept = new List<DAL.Contact>();

            //if (_contacts.Count > 0)
            //{
            //    _contacts = _contacts.Where(x => x.ContactName.ToLower().Contains(departementhquery)).Take(10).ToList();
            //}

            //return _contacts;
        }
Пример #5
0
        public List<DAL.Contact> GetAllContacts()
        {
            _contacts = new List<DAL.Contact>();
            //string query = "SELECT * FROM tb_CONTACT";
            //Retrieving data using stored procedure that we created in the DB
            string query = "SP_GET_ALL_CONTACTS";

            try
            {

                SqlCommand readcommand = new SqlCommand();
                readcommand.CommandText = query;
                readcommand.Connection = MyConnection;
                readcommand.CommandType = CommandType.StoredProcedure;
                readcommand.Parameters.AddWithValue("@userId","5F45B55F-4851-4BC9-AF27-76757F5B1C09"); //Hardcoded the Id of the current user because there is no authentication in place
                MyConnection.Open();
                SqlDataReader reader = null;

                reader = readcommand.ExecuteReader();
                while (reader.Read())
                {
                    var aContact = new DAL.Contact
                    {
                        ContactName = reader["ContactName"].ToString(),
                        ContactPhone = reader["Telephone"].ToString(),
                        ContactEmail = reader["Email_Address"].ToString(),
                        ContactTag = reader["ContactTag"].ToString(),
                        ContactLocation = reader["ContactLocation"].ToString(),
                    };

                    string strContactId = reader["ContactId"].ToString().Trim().ToUpper();
                    if (!string.IsNullOrEmpty(strContactId))
                    {
                        aContact.ContactId = new Guid(strContactId);
                    }

                    string strDeptId = reader["Dpt_ID"].ToString().Trim().ToUpper();
                    if (!string.IsNullOrEmpty(strDeptId))
                    {
                        aContact.ContactDeptId = new Guid(strDeptId);
                    }

                    string strUserId = reader["UserID"].ToString().Trim().ToUpper();
                    if (!string.IsNullOrEmpty(strUserId))
                    {
                        aContact.ContactUserId = new Guid(strUserId);
                    }

                    string strContactPhototId =
                           reader["ContactPhotoId"].ToString().Trim().ToUpper();
                    if (!string.IsNullOrEmpty(strContactPhototId))
                    {
                        aContact.ContactPhotoId = new Guid(strContactPhototId);
                    }
                    _contacts.Add(aContact);
                }

                _resultMessage = "Success";
            }

            catch (Exception sqlException)
            {
                //for testing purpose
                SqlRelatedErroMessage = sqlException.Message;
            }

            MyConnection.Close();

            return _contacts;
        }
Пример #6
0
        protected void ImportButton_Click(object sender, EventArgs e)
        {
            long count = 0;
            string firstName=null;
            string lastname=null;
            StreamReader Sr =new StreamReader(@"C:\Users\rizwanul.islam\My Projects\Default Collections\C3\C3App\C3App\LeadImport.csv");
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            // System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
            string s;
            bool passedFirstline = false;
            while (!Sr.EndOfStream)
            {
                s = Sr.ReadLine();
                string[] value = s.Split(',');
                if (passedFirstline)
                {
                    DAL.Contact contact=new DAL.Contact();
                    if (value[0]!=null)
                    {
                        firstName = value[0];
                        contact.FirstName = firstName;
                    }
                    else
                    {
                        contact.FirstName = "None";
                    }
                    if (value[1] != null)
                    {
                        lastname = value[1];
                        contact.LastName = lastname;
                    }
                    else
                    {
                        contact.LastName = "None";
                    }
                    if (value[2] != null)
                    {
                        contact.PrimaryEmail = value[2];
                    }
                    else
                    {
                        contact.PrimaryEmail = "None";
                    }
                    contact.CompanyID = Convert.ToInt32(Session["CompanyID"]);
                    contact.CreatedBy = Convert.ToInt64(Session["UserID"]);
                    contact.CreatedTime = DateTime.Now;
                    contact.ModifiedTime = DateTime.Now;
                    Int64 contactID = contactBL.InsertContact(contact);
                    if (contactID!=null)
                    {
                        Lead lead=new Lead();
                        lead.ContactID = contactID;
                        lead.FirstName = firstName;
                        lead.LastName = lastname;
                        lead.CompanyID = Convert.ToInt32(Session["CompanyID"]);
                        lead.CreatedBy = Convert.ToInt64(Session["UserID"]);
                        lead.CreatedTime = DateTime.Now;
                        lead.ModifiedTime = DateTime.Now;
                        Int64 leadID = leadBL.InsertLeads(lead);
                        if (leadID!=0)
                        {
                            count++;
                        }
                    }
                }
                else
                {
                    passedFirstline = true;
                }

            }
            Literal1.Text = "Successfully Imported";
            Label1.Text = count +" "+"Data has been successfully imported to lead";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "ShowAlertModal();", true);
        }
Пример #7
0
        //для сопоставления Id - name
        public async Task <IEnumerable <DAL.Sale> > CheckNameId(IEnumerable <DAL.Sale> Entities)
        {
            var _contactRepository = new GenericRepository <DAL.Contact>();

            IEnumerable <DAL.Client> clients = await GetAll();

            foreach (var sale in Entities)
            {
                Guid idClient = new Guid();
                if (clients.Any())
                {
                    var clients1 = clients.Where(c => c.Name == sale.ClientName);
                    var i        = clients1.Where(x => x != null).Select(c => c.Id);
                    if (i.Count() > 0)
                    {
                        idClient = i.Where(x => x != null).First();
                    }
                    //создать в БД
                    else
                    {
                        //контакт
                        DAL.Contact contact = new DAL.Contact();
                        contact.Id       = Guid.NewGuid();
                        contact.LastName = sale.ClientName;
                        _contactRepository.Add(contact);
                        //SaveChanges();
                        //клиент
                        DAL.Client client = new DAL.Client();
                        client.Id        = Guid.NewGuid();
                        client.Name      = sale.ClientName;
                        client.ContactId = contact.Id;
                        Add(client);
                        //SaveChanges();
                        idClient = client.Id;

                        clients = await GetAll();
                    }
                }
                //создать в БД
                else
                {
                    //контакт
                    DAL.Contact contact = new DAL.Contact();
                    contact.Id       = Guid.NewGuid();
                    contact.LastName = sale.ClientName;
                    _contactRepository.Add(contact);
                    //клиент
                    DAL.Client client = new DAL.Client();
                    client.Id        = Guid.NewGuid();
                    client.Name      = sale.ClientName;
                    client.ContactId = contact.Id;
                    Add(client);
                    idClient = client.Id;

                    clients = await GetAll();
                }
                sale.ClientId = idClient;
            }

            return(Entities);
        }