protected void btn_CreateAccount_Click(object sender, EventArgs e)
        {
            try
            {
                using (AdGiverRT adGiverRt = new AdGiverRT())
                {
                    UserInformationRT aUserInformationRt = new UserInformationRT();
                    UserInfo          aUserInfo          = new UserInfo();
                    AdGiver           adGiver            = new AdGiver();
                    adGiver = CreateAdGiver();
                    if (adGiver != null)
                    {
                        // const int userInGroup = 7; //for addgiver
                        adGiverRt.AddAdGiver(adGiver);
                        aUserInfo = CreateUserInfo(adGiver.IID);
                        aUserInformationRt.AddUserInfo(aUserInfo);
                    }
                    else
                    {
                        if (txtPassword.Text == string.Empty || txtPassword.Text == "")
                        {
                            labelMessage.Text = "Please enter your password";
                        }
                        else if (txtConfirmPassword.Text == "" || txtConfirmPassword.Text == string.Empty)
                        {
                            labelMessage.Text = "Please comfirm your password";
                        }
                        else if (txtPassword.Text != txtConfirmPassword.Text)
                        {
                            labelMessage.Text = "password doesn't match";
                        }
                        else if (txtPassword.Text.Length < 6)
                        {
                            labelMessage.Text = "password too short, enter at least 6 character";
                        }
                        else
                        {
                            labelMessage.Text = string.Format("The email address {0} already registered ",
                                                              txtEmail.Text.Trim());
                        }
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                        //ClearField();
                        return;
                    }

                    labelMessage.Text      = "you have registered successfully...and your user ID is " + adGiver.EmailID;
                    labelMessage.ForeColor = System.Drawing.Color.Green;
                    ClearField();
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
예제 #2
0
        protected void btnPostAd_Click(object sender, EventArgs e)
        {
            try
            {
                using (MaterialRT receiverTransfer = new MaterialRT())
                {
                    AdGiverRT adGiverRt = new AdGiverRT();
                    string    matCode   = string.Empty;
                    AdGiver   adGiver   = new AdGiver();
                    Material  material  = CreateMaterial();

                    if (material.AdGiverID == -1)
                    {
                        adGiver = CreateAdGiver();
                        if (adGiver != null)
                        {
                            adGiverRt.AddAdGiver(adGiver);
                            material.AdGiverID = adGiverRt.GetAdGiverIDByEmail(adGiver.EmailID).IID;
                            receiverTransfer.AddMaterial(material);
                            matCode = material.Code;
                        }
                    }
                    else
                    {
                        receiverTransfer.AddMaterial(material);
                        matCode = material.Code;
                    }

                    if (material.IID > 0)
                    {
                        labelMessage.Text      = "Your ad successfully posted...and your material code is " + matCode;
                        labelMessage.ForeColor = System.Drawing.Color.Green;
                        ClearField();
                    }
                    else if (adGiver == null)
                    {
                        labelMessage.Text      = "This email already taken...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        labelMessage.Text      = "Data not saved...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }