public string save(MemberEntry aMemberEntry)
 {
     try
     {
         aSqlConnection.Open();
         SqlCommand command = new SqlCommand("USPInsertIntoMemberCode", aSqlConnection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@memberName", aMemberEntry.name);
         command.Parameters.AddWithValue("@roomNo", aMemberEntry.roomNo);
         command.Parameters.AddWithValue("@address", aMemberEntry.address);
         command.Parameters.AddWithValue("@dateOfEntry", aMemberEntry.dateOfEntry);
         int effectedRows = command.ExecuteNonQuery();
         if (effectedRows > 0)
         {
             return "Member saved successfully.";
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
     finally
     {
         if (aSqlConnection != null && aSqlConnection.State == ConnectionState.Open)
         {
             aSqlConnection.Close();
         }
     }
     return "Error while saving member.";
 }
 public EditMemberCodeEntryUI(MemberEntry aEditMemberEntry)
     : this()
 {
     this.memberIdTextBox.Text = aEditMemberEntry.memberId.ToString();
     memberIdTextBox.Enabled = false;
     this.memberNameTextBox.Text = aEditMemberEntry.name;
     this.roomNoTextBox.Text = aEditMemberEntry.roomNo;
     this.addressTextBox.Text = aEditMemberEntry.address;
     dateTimePicker1.Value = aEditMemberEntry.dateOfEntry;
 }
コード例 #3
0
 public string save(MemberEntry aMemberEntry)
 {
     if ((aMemberEntry.name == string.Empty)||(aMemberEntry.roomNo==string.Empty)||(aMemberEntry.address==string.Empty))
     {
         return "please fill up all field";
     }
     else
     {
         MemberEntryValidator validator = new MemberEntryValidator();
         validator.validateNameAndRoomNumber(aMemberEntry.name,aMemberEntry.roomNo);
         return aMemberCodeEntryGateway.save(aMemberEntry);
     }
 }
 private void updateButton_Click(object sender, EventArgs e)
 {
     try
     {
         MemberCodeEntryBLL aMemberCodeEntryBll = new MemberCodeEntryBLL();
         MemberEntry aMemberEntry = new MemberEntry(Convert.ToInt32(memberIdTextBox.Text), memberNameTextBox.Text,
             roomNoTextBox.Text, addressTextBox.Text, dateTimePicker1.Value);
         string msg = aMemberCodeEntryBll.update(aMemberEntry);
         MessageBox.Show(msg, @"Message");
         Hide();
         new MemberCodeEntryUI().Show();
     }
     catch(Exception exception)
     {
         MessageBox.Show(exception.Message,@"Message");
     }
 }
        public System.Collections.Generic.List<DAO.MemberEntry> getMemberCodeInfo()
        {
            try
            {
                aSqlConnection.Open();
                SqlCommand command = new SqlCommand("uspMembers", aSqlConnection);
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader aReader = command.ExecuteReader();
                memberCodeList = new List<MemberEntry>();
                if (aReader.HasRows)
                {
                    while (aReader.Read())
                    {
                        MemberEntry aMemberEntry = new MemberEntry();
                        aMemberEntry.memberId = Convert.ToInt32(aReader[0].ToString());
                        aMemberEntry.name = aReader[1].ToString();
                        aMemberEntry.roomNo = aReader[2].ToString();
                        aMemberEntry.address = aReader[3].ToString();
                        aMemberEntry.dateOfEntry = (DateTime)aReader[4];
                        memberCodeList.Add(aMemberEntry);
                    }
                }

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                if (aSqlConnection != null && aSqlConnection.State == ConnectionState.Open)
                {
                    aSqlConnection.Close();
                }
            }
            return memberCodeList;
        }
コード例 #6
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     try
     {
         MemberEntry aMemberEntry = new MemberEntry(memberNameTextBox.Text, roomNoTextBox.Text, addressTextBox.Text, dateTimePicker1.Value);
         string msg = aMemberCodeEntryBll.save(aMemberEntry);
         showDataInDataGridView();
         MessageBox.Show(msg, @"Message");
         clearTextBoxes();
         MemberCodeEntryUI_Load(0, null);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
 public string update(MemberEntry aMemberEntry)
 {
     try
     {
         aSqlConnection.Open();
         SqlCommand command = new SqlCommand("USPMemberInfoUpdation", aSqlConnection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@memberId", aMemberEntry.memberId);
         command.Parameters.AddWithValue("@memberName", aMemberEntry.name);
         command.Parameters.AddWithValue("@roomNo", aMemberEntry.roomNo);
         command.Parameters.AddWithValue("@address", aMemberEntry.address);
         command.Parameters.AddWithValue("@dateOfEntry", aMemberEntry.dateOfEntry);
         int effectedRows = command.ExecuteNonQuery();
         if (effectedRows > 0)
         {
             return @"Memeber Information is updated";
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
     finally
     {
         if (aSqlConnection != null && aSqlConnection.State == ConnectionState.Open)
         {
             aSqlConnection.Close();
         }
     }
     return "Error while updating member.";
 }
コード例 #8
0
 public string update(MemberEntry aMemberEntry)
 {
     new EditMemberCodeEntryValidator().isRoomNumberAndMemberNameValid(aMemberEntry.roomNo, aMemberEntry.name);
        return aMemberCodeEntryGateway.update(aMemberEntry);
 }