コード例 #1
0
        private CMemberShip GetFormData()
        {
            CMemberShip oMember = new CMemberShip();

            oMember.Branch                = currentBranch.CompBrn_Branch;
            oMember.ID                    = txtMembeHiddenID.Text.Trim();
            oMember.MembershipID          = txtMemberID.Text.Trim();
            oMember.MemberName            = txtMemberName.Text.Trim();
            oMember.Mobile                = txtMobile.Text.Trim();
            oMember.DateOfBirth           = dtpDateOfBirth.Value;
            oMember.Fromdate              = dtpFromDate.Value;
            oMember.Todate                = dtpToDate.Value;
            oMember.Address               = txtAddress.Text.Trim();
            oMember.Area                  = txtArea.Text.Trim();
            oMember.PostCode              = txtPostCode.Text.Trim();
            oMember.Phone                 = txtPhone.Text.Trim();
            oMember.Email                 = txtEmail.Text.Trim();
            oMember.Occupation            = txtOccuption.Text.Trim();
            oMember.FamilyMember          = int.Parse(txtFamilyMember.Text.Trim());
            oMember.Member_DiscountAmount = float.Parse(txtMemberDiscountAmount.Text.Trim());
            if (rbYes.Checked)
            {
                oMember.IsActiveMenber = 1;
            }
            else if (rbNo.Checked)
            {
                oMember.IsActiveMenber = 0;
            }
            oMember.UpdateBy   = currentUser.User_OID;
            oMember.UpdateDate = DateTime.Now;
            return(oMember);
        }
コード例 #2
0
 private void lvMemberList_DoubleClick(object sender, EventArgs e)
 {
     if (lvMemberList.Items.Count > 0)
     {
         CMemberShip oMembership = lvMemberList.SelectedItems[0].Tag as CMemberShip;
         if (oMembership != null)
         {
             txtMembeHiddenID.Text = oMembership.ID;
             txtMemberID.Text      = oMembership.MembershipID;
             txtMemberName.Text    = oMembership.MemberName;
             txtMobile.Text        = oMembership.Mobile;
             dtpDateOfBirth.Value  = oMembership.DateOfBirth;
             dtpFromDate.Value     = oMembership.Fromdate;
             dtpToDate.Value       = oMembership.Todate;
             txtAddress.Text       = oMembership.Address;
             txtArea.Text          = oMembership.Area;
             txtPostCode.Text      = oMembership.PostCode;
             txtPhone.Text         = oMembership.Phone;
             txtEmail.Text         = oMembership.Email;
             txtOccuption.Text     = oMembership.Occupation;
             txtFamilyMember.Text  = oMembership.FamilyMember.ToString();
             if (oMembership.IsActiveMenber == 1)
             {
                 rbYes.Checked = true;
             }
             else if (oMembership.IsActiveMenber == 0)
             {
                 rbNo.Checked = true;
             }
         }
     }
 }
コード例 #3
0
        private static CMemberShip SetMembership(SqlDataReader oReader)
        {
            CMemberShip oMembership = new CMemberShip();

            oMembership.ID                    = oReader["Member_OID"].ToString();
            oMembership.Branch                = oReader["Member_Branch"].ToString();
            oMembership.MembershipID          = oReader["Member_MembershipID"].ToString();
            oMembership.MemberName            = oReader["Member_Name"].ToString();
            oMembership.Mobile                = oReader["Member_Mobile"].ToString();
            oMembership.DateOfBirth           = DateTime.Parse(oReader["Member_DateOfBirth"].ToString());
            oMembership.Fromdate              = DateTime.Parse(oReader["Member_FromDate"].ToString());
            oMembership.Todate                = DateTime.Parse(oReader["Member_ToDate"].ToString());
            oMembership.Address               = oReader["Member_Address"].ToString();
            oMembership.Area                  = oReader["Member_Area"].ToString();
            oMembership.PostCode              = oReader["Member_PostCode"].ToString();
            oMembership.Phone                 = oReader["Member_Phone"].ToString();
            oMembership.Email                 = oReader["Member_Email"].ToString();
            oMembership.Occupation            = oReader["Member_Occupation"].ToString();
            oMembership.FamilyMember          = int.Parse(oReader["Member_FamilyMember"].ToString());
            oMembership.Member_DiscountAmount = float.Parse(oReader["Member_DiscountAmount"].ToString());
            if ((bool)oReader["Member_IsActive"] == true)
            {
                oMembership.IsActiveMenber = 1;
            }
            else if ((bool)oReader["Member_IsActive"] == false)
            {
                oMembership.IsActiveMenber = 0;
            }
            return(oMembership);
        }
コード例 #4
0
        public CResult ReadAll()
        {
            List <CMemberShip> oMemberList = new List <CMemberShip>();

            oResult = new CResult();
            conn    = oConnManager.GetConnection(out s_DBError);
            if (conn != null)
            {
                try
                {
                    SqlCommand cmd = new SqlCommand();

                    cmd.Connection  = conn;
                    cmd.CommandText = "Select * from t_Curr order by Curr_OID";
                    cmd.CommandType = CommandType.Text;

                    SqlDataReader oReader = cmd.ExecuteReader();
                    if (oReader.HasRows)
                    {
                        while (oReader.Read())
                        {
                            CMemberShip oMembership = new CMemberShip();
                            oMembership.ID     = oReader["Curr_OID"].ToString();
                            oMembership.Branch = oReader["Curr_Branch"].ToString();
                            oMembership.Branch = oReader["Curr_Code"].ToString();
                            oMembership.Branch = oReader["Curr_Name"].ToString();
                            oMemberList.Add(oMembership);
                        }
                    }
                    oReader.Close();

                    oResult.IsSuccess = true;
                    oResult.Data      = oMemberList;
                }
                catch (SqlException e)
                {
                    oResult.IsSuccess = false;
                    oResult.ErrMsg    = e.Message;
                }
                finally
                {
                    oConnManager.Close();
                }
            }
            else
            {
                oResult.IsSuccess = false;
                oResult.ErrMsg    = s_DBError;
            }

            return(oResult);
        }
コード例 #5
0
        public CResult ReadAllByDateAndIsActive(string Branch, string MembershipID)
        {
            List <CMemberShip> oMemberList = new List <CMemberShip>();

            oResult = new CResult();
            conn    = oConnManager.GetConnection(out s_DBError);
            if (conn != null)
            {
                try
                {
                    SqlCommand cmd = new SqlCommand();

                    cmd.Connection  = conn;
                    cmd.CommandText = "sp_ReadAllByDateAndIsActiveMember";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Member_Bracch", Branch);
                    cmd.Parameters.AddWithValue("@Member_MembershipID", MembershipID);

                    SqlDataReader oReader = cmd.ExecuteReader();
                    if (oReader.HasRows)
                    {
                        while (oReader.Read())
                        {
                            CMemberShip oMembership = SetMembership(oReader);
                            oMemberList.Add(oMembership);
                        }
                    }
                    oReader.Close();

                    oResult.IsSuccess = true;
                    oResult.Data      = oMemberList;
                }
                catch (SqlException e)
                {
                    oResult.IsSuccess = false;
                    oResult.ErrMsg    = e.Message;
                }
                finally
                {
                    oConnManager.Close();
                }
            }
            else
            {
                oResult.IsSuccess = false;
                oResult.ErrMsg    = s_DBError;
            }

            return(oResult);
        }
コード例 #6
0
        private CMemberShip Getformdata()
        {
            CMemberShip oMembership = new CMemberShip();

            oMembership.Branch                = currentBranch.CompBrn_Code;
            oMembership.MembershipID          = txtMembershipID.Text.Trim();
            oMembership.MemberName            = txtName.Text.Trim();
            oMembership.Mobile                = txtMobile.Text.Trim();
            oMembership.Fromdate              = dtpFromDate.Value;
            oMembership.Todate                = dtpToDate.Value;
            oMembership.Member_DiscountAmount = Convert.ToInt32(txtDiscount.Text);
            oMembership.Creator               = currentUser.User_OID;
            oMembership.CreationDate          = DateTime.Now;
            return(oMembership);
        }
コード例 #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            CMemberShip   oMembership   = Getformdata();
            CMemberShipBO oMembershipBO = new CMemberShipBO();
            CResult       oresult       = new CResult();

            if (validatedata())
            {
                oresult = oMembershipBO.Create(oMembership);
                if (oresult.IsSuccess)
                {
                    MessageBox.Show("Member Data Successfully Saved", "ETLIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearFromData(groupBox1);
                }
            }
        }
コード例 #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            CMemberShip   oMemberShip = new CMemberShip();
            CMemberShipBO oMemberBO   = new CMemberShipBO();
            CResult       oResult     = new CResult();

            if (ValidateFormData())
            {
                if (txtMembeHiddenID.Text != "")
                {
                    oResult = oMemberBO.Update(GetFormData());
                    if (oResult.IsSuccess)
                    {
                        MessageBox.Show("Data Upated Successfully", "ETLIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ClearFromData(groupBox1);
                        LoadMemberList();
                    }
                }
            }
        }
コード例 #9
0
        public CResult Create(CMemberShip oMemberShip)
        {
            oResult = new CResult();
            conn    = oConnManager.GetConnection(out s_DBError);
            if (conn != null)
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;

                cmd.Transaction = oConnManager.BeginTransaction();
                try
                {
                    StringBuilder sBuilder = new StringBuilder();
                    sBuilder.Append("DECLARE @NextId NCHAR(24);");
                    sBuilder.Append("EXEC sp_GetNextId 'Member_OID','Member', @Member_Branch, @NextId OUTPUT;");
                    sBuilder.Append(" Insert into t_Member values(@NextId,@Member_Branch,");
                    sBuilder.Append("@Member_MembershipID,@Member_Name,@Member_Mobile,@Member_DateOfBirth,");
                    sBuilder.Append("@Member_FromDate,@Member_ToDate,@Member_Address,");
                    sBuilder.Append("@Member_Area,@Member_PostCode,@Member_Phone,@Member_Email,@Member_Occupation,@Member_FamilyMember,");
                    sBuilder.Append("@Member_CreatedBy,@Member_CreationDate,@Member_UpdateBy,@Member_UpdateDate,@Member_IsActive,@Member_DiscountAmount)");

                    cmd.CommandText = sBuilder.ToString();
                    cmd.CommandType = CommandType.Text;

                    cmd.Parameters.AddWithValue("@Member_Branch", oMemberShip.Branch);
                    cmd.Parameters.AddWithValue("@Member_MembershipID", oMemberShip.MembershipID);
                    cmd.Parameters.AddWithValue("@Member_Name", oMemberShip.MemberName);
                    cmd.Parameters.AddWithValue("@Member_Mobile", oMemberShip.Mobile);
                    cmd.Parameters.AddWithValue("@Member_DateOfBirth", oMemberShip.DateOfBirth);
                    cmd.Parameters.AddWithValue("@Member_FromDate", oMemberShip.Fromdate);
                    cmd.Parameters.AddWithValue("@Member_ToDate", oMemberShip.Todate);
                    cmd.Parameters.AddWithValue("@Member_Address", oMemberShip.Address);
                    cmd.Parameters.AddWithValue("@Member_Area", oMemberShip.Area);
                    cmd.Parameters.AddWithValue("@Member_PostCode", oMemberShip.PostCode);
                    cmd.Parameters.AddWithValue("@Member_Phone", oMemberShip.Phone);
                    cmd.Parameters.AddWithValue("@Member_Email", oMemberShip.Email);
                    cmd.Parameters.AddWithValue("@Member_Occupation", oMemberShip.Occupation);
                    cmd.Parameters.AddWithValue("@Member_FamilyMember", oMemberShip.FamilyMember);
                    cmd.Parameters.AddWithValue("@Member_CreatedBy", oMemberShip.Creator);
                    cmd.Parameters.AddWithValue("@Member_CreationDate", oMemberShip.CreationDate);
                    cmd.Parameters.AddWithValue("@Member_UpdateBy", "");
                    cmd.Parameters.AddWithValue("@Member_UpdateDate", "");
                    cmd.Parameters.AddWithValue("@Member_IsActive", 1);
                    cmd.Parameters.AddWithValue("@Member_DiscountAmount", oMemberShip.Member_DiscountAmount);

                    cmd.ExecuteNonQuery();
                    oConnManager.Commit();
                    oResult.IsSuccess = true;
                }
                catch (SqlException e)
                {
                    string sRollbackError = oConnManager.Rollback();

                    oResult.IsSuccess = false;
                    oResult.ErrMsg    = sRollbackError.Equals("") ? oConnManager.GetErrorMessage(e) : sRollbackError;
                }
                finally
                {
                    oConnManager.Close();
                }
            }
            else
            {
                oResult.IsSuccess = false;
                oResult.ErrMsg    = s_DBError;
            }

            return(oResult);
        }
コード例 #10
0
        public CResult Update(CMemberShip oMemberShip)
        {
            oResult = new CResult();
            conn    = oConnManager.GetConnection(out s_DBError);
            if (conn != null)
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;

                cmd.Transaction = oConnManager.BeginTransaction();
                try
                {
                    StringBuilder sBuilder = new StringBuilder();
                    sBuilder.Append("Update t_Member set Member_Branch=@Member_Branch,Member_MembershipID=@Member_MembershipID,Member_Name=@Member_Name,");
                    sBuilder.Append("Member_Mobile=@Member_Mobile,Member_DateOfBirth=@Member_DateOfBirth,Member_FromDate=@Member_FromDate,Member_ToDate=@Member_ToDate,");
                    sBuilder.Append("Member_Address=@Member_Address,Member_Area=@Member_Area,Member_PostCode=@Member_PostCode,Member_Phone=@Member_Phone,");
                    sBuilder.Append("Member_Email=@Member_Email,Member_Occupation=@Member_Occupation,Member_FamilyMember=@Member_FamilyMember,");
                    sBuilder.Append("Member_UpdateBy=@Member_UpdateBy,Member_UpdateDate=@Member_UpdateDate,Member_IsActive=@Member_IsActive,Member_DiscountAmount=@Member_DiscountAmount ");
                    sBuilder.Append("where Member_OID=@MemberOID");
                    cmd.CommandText = sBuilder.ToString();
                    cmd.CommandType = CommandType.Text;

                    cmd.Parameters.AddWithValue("@MemberOID", oMemberShip.ID);
                    cmd.Parameters.AddWithValue("@Member_Branch", oMemberShip.Branch);
                    cmd.Parameters.AddWithValue("@Member_MembershipID", oMemberShip.MembershipID);
                    cmd.Parameters.AddWithValue("@Member_Name", oMemberShip.MemberName);
                    cmd.Parameters.AddWithValue("@Member_Mobile", oMemberShip.Mobile);
                    cmd.Parameters.AddWithValue("@Member_DateOfBirth", oMemberShip.DateOfBirth);
                    cmd.Parameters.AddWithValue("@Member_FromDate", oMemberShip.Fromdate);
                    cmd.Parameters.AddWithValue("@Member_ToDate", oMemberShip.Todate);
                    cmd.Parameters.AddWithValue("@Member_Address", oMemberShip.Address);
                    cmd.Parameters.AddWithValue("@Member_Area", oMemberShip.Area);
                    cmd.Parameters.AddWithValue("@Member_PostCode", oMemberShip.PostCode);
                    cmd.Parameters.AddWithValue("@Member_Phone", oMemberShip.Phone);
                    cmd.Parameters.AddWithValue("@Member_Email", oMemberShip.Email);
                    cmd.Parameters.AddWithValue("@Member_Occupation", oMemberShip.Occupation);
                    cmd.Parameters.AddWithValue("@Member_FamilyMember", oMemberShip.FamilyMember);
                    cmd.Parameters.AddWithValue("@Member_UpdateBy", oMemberShip.UpdateBy);
                    cmd.Parameters.AddWithValue("@Member_UpdateDate", oMemberShip.UpdateDate);
                    cmd.Parameters.AddWithValue("@Member_IsActive", oMemberShip.IsActiveMenber);
                    cmd.Parameters.AddWithValue("@Member_DiscountAmount", oMemberShip.Member_DiscountAmount);

                    cmd.ExecuteNonQuery();
                    oConnManager.Commit();
                    oResult.IsSuccess = true;
                }
                catch (SqlException e)
                {
                    string sRollbackError = oConnManager.Rollback();

                    oResult.IsSuccess = false;
                    oResult.ErrMsg    = sRollbackError.Equals("") ? oConnManager.GetErrorMessage(e) : sRollbackError;
                }
                finally
                {
                    oConnManager.Close();
                }
            }
            else
            {
                oResult.IsSuccess = false;
                oResult.ErrMsg    = s_DBError;
            }

            return(oResult);
        }