public List<ICustomerBO> viewallListBO()
         {
 
             string ConnectionString = "";
 
             SqlConnection connection = new SqlConnection(ConnectionString);
             connection.Open();
             SqlCommand cmd = new SqlCommand();
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.CommandText = "sp_viewemp7";
             cmd.Connection = connection;
             SqlDataReader reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 int id = Convert.ToInt32(reader["id"]);
                 string name = reader["employeename"].ToString();
                 DateTime dob = Convert.ToDateTime(reader["dob"]);
                 string locn = reader["location"].ToString();
                 string gender = reader["gender"].ToString();
                 DateTime doj = Convert.ToDateTime(reader["doj"]);
                 int exp = Convert.ToInt32(reader["experience"]);
                 int ctc = Convert.ToInt32(reader["ctc"]);
                 string desg = reader["designation"].ToString();
                 string head = reader["unithead"].ToString();
                 int proj =Convert.ToInt32( reader["projectid"]);
 
                 ICustomerBO employee=BOFactory.CustomerBOFactory.ADDEMPLOYEE(id, name, dob, locn, gender, doj, exp, ctc, desg, head, proj);
                 emplist.Add(employee);
 
             }
             connection.Close();
             return emplist;
         }
         public bool EDITCustomer(ICustomerBO bb)
          {
              bool flag = false;
              string ConnectionString = "";
 
              SqlConnection connection = new SqlConnection(ConnectionString);
              connection.Open();
              SqlCommand command = new SqlCommand();
              command.CommandType = CommandType.StoredProcedure;
              command.CommandText = "sp_editemploye";
              command.Connection = connection;
              SqlConnection conn = new SqlConnection();
              command.Parameters.AddWithValue("@id", bb.id);
              command.Parameters.AddWithValue("@employeename", bb.empname);
              command.Parameters.AddWithValue("@dob", bb.dob);
              command.Parameters.AddWithValue("@location", bb.location);
              command.Parameters.AddWithValue("@gender", bb.gender);
              command.Parameters.AddWithValue("@doj", bb.doj);
              command.Parameters.AddWithValue("@experience", bb.experience);
              command.Parameters.AddWithValue("@ctc", bb.ctc);
              command.Parameters.AddWithValue("@designation", bb.designation);
              command.Parameters.AddWithValue("@unithead", bb.unithead);
              command.Parameters.AddWithValue("@projectid", bb.projectid);
              int rowaffected = command.ExecuteNonQuery();
              connection.Close();
              if (rowaffected > 0)
              {
                  flag = true;
              }
              return flag;
          }
        public void LoadClicked()
        {
            try
            {
                ICustomerBO customerBo = _service.CreateNew();

                _viewModel = new CustomerViewModel(customerBo);

                _view.ShowCustomer(_viewModel);
            }
            catch (Exception ex)
            {
                _view.ShowError(ex.ToString());
            }
        }
         public int addemployee(ICustomerBO b)
         {
             string connectionstring = "Server= LENOVO\\SQLEXPRESS, Authentication=Windows Authentication, Database= tempdb";
 
 
 
             SqlConnection connection = new SqlConnection(connectionstring);
 
             connection.Open();
 
             SqlCommand command = new SqlCommand();
             command.CommandType = CommandType.StoredProcedure;
             command.CommandText = "sp_addemployee";
 
             command.Connection = connection;
 
             command.Parameters.AddWithValue("@employeename", b.empname);
             command.Parameters.AddWithValue("@dob", b.dob);
             command.Parameters.AddWithValue("@location", b.location);
             command.Parameters.AddWithValue("@gender", b.gender);
             command.Parameters.AddWithValue("@doj", b.doj);
             command.Parameters.AddWithValue("@experience", b.experience);
             command.Parameters.AddWithValue("@CTC", b.ctc);
             command.Parameters.AddWithValue("@designation", b.designation);
             command.Parameters.AddWithValue("@unithead", b.unithead);
             command.Parameters.AddWithValue("@projectid",b.projectid);
 
             command.Parameters.AddWithValue("@id", 0);
 
             command.Parameters["@id"].Direction = ParameterDirection.Output;
 
             int rowaffected = command.ExecuteNonQuery();
 
 
             connection.Close();
 
             if(rowaffected>0)
             {
                 return rowaffected;
             }
 
             else
             {
                 return 0;
             }                                    
               }
Ejemplo n.º 5
0
        public static ICustomerDTO ToDTO(ICustomerBO bo)
        {
            ICustomerDTO dto = new CustomerDTO();

            dto.CustomerId = bo.Id;
            if (bo.Name.Contains(" "))
            {
                string[] names = bo.Name.Split(' ');
                dto.FirstName = names[0];
                dto.LastName  = names[1];
            }
            else
            {
                dto.FirstName = bo.Name;
            }
            dto.Age = bo.Age;

            return(dto);
        }
        public void SaveClicked()
        {
            try
            {
                _view.ReadUserInput();

                ICustomerBO customerDataEntity = _viewModel.CustomerDataEntity;
                bool        duplicateExist     = !IsDuplicateOfExisting(customerDataEntity);
                if (duplicateExist)
                {
                    _service.Save(customerDataEntity);
                    _view.Close();
                }
                else
                {
                    _view.ShowError(string.Format("Customer '{0}' already exist", _viewModel.Name));
                }
            }
            catch (Exception ex)
            {
                _view.ShowError(ex.ToString());
            }
        }
         public bool LOGIN(ICustomerBO l)
         {
             bool flag = false;
 
             string connectionstring = "Data Source=sql1;" + ";" + "user id=;"
                 + "password=tcstvm;";
 
             SqlConnection connection = new SqlConnection(connectionstring);
 
             connection.Open();
 
             SqlCommand command = new SqlCommand();
 
             command.CommandType = CommandType.StoredProcedure;
 
             command.CommandText = "sp_loginview";
 
             command.Connection = connection;
 
             SqlDataReader reader = command.ExecuteReader();
 
             while(reader.Read())
             {
                 string name = reader["UserName"].ToString();
                 string pwd = reader["Password"].ToString();
 
                 if((name==l.name)&&(pwd==l.pwd))
                 {
                     flag = true;
                 }
             }
 
              connection.Close();
 
             return flag;
 
         }
        private bool IsDuplicateOfExisting(ICustomerBO newCustomerDataEntity)
        {
            ICustomerBO duplicateCustomerDataEntity = _service.GetCustomer(newCustomerDataEntity.Id);

            return(duplicateCustomerDataEntity != null);
        }
 public void Save(ICustomerBO dto)
 {
     _dao.Add(CustomerDTOAdapter.ToDTO(dto));
 }
 public void Save(ICustomerBO customer)
 {
     _factory.Save(customer);
 }
 public CustomerViewModel(ICustomerBO model)
 {
     _model = model;
 }