예제 #1
0
        public IActionResult Save(OwnerMain OwnerDetails)
        {
            try
            {
                if (String.IsNullOrEmpty(OwnerDetails.OwnerName))
                {
                    return(View("Edit", OwnerDetails));
                }
                if (OwnerDetails.OwnerFieldValues != null)
                {
                    foreach (var field in OwnerDetails.OwnerFieldValues)
                    {
                        if (field.Required && String.IsNullOrEmpty(field.FieldValue))
                        {
                            return(View("Edit", OwnerDetails));
                        }
                    }
                }
                db.Owners.Update(OwnerDetails);
                db.SaveChanges();

                ViewData["Message"] = "Successfully saved";
                return(RedirectToAction("Index", "Owner"));
            }
            catch (Exception ex)
            {
                LogFilter.Write(db, HttpContext.Request.QueryString.ToString(), HttpContext.Request.Path, HttpContext.Session.GetString("UserID"), ex);
                return(View("Error", ex));
            }
        }
//Owner login code
        public static void startOwnLogin(TextBox username, TextBox password)
        {
            try
            {
                //get data
                logCommand = new SqlCommand("SELECT * FROM group1fa202330.WorkerLogin where UserName=@UserName and Password =@Password and Position = 'Owner';", logConnection);
                logCommand.Parameters.AddWithValue("@UserName", username.Text);
                logCommand.Parameters.AddWithValue("@Password", password.Text);
                logAdapter.SelectCommand = logCommand;
                logAdapter.Fill(logOwnInfoDT);
                int i = logCommand.ExecuteNonQuery();
                if (logOwnInfoDT.Rows.Count > 0)//redirects to next page
                {
                    MessageBox.Show("Access Granted");
                    OwnerMain form2 = new OwnerMain();
                    form2.Text = "LandscaperZ - " + username.Text;
                    form2.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please enter Correct Username and Password");
                }
                logAdapter.Dispose();
                logCommand.Dispose();
                logOwnInfoDT.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error In Logging In", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        public IActionResult AddOwner(OwnerMain OwnerDetails)
        {
            try
            {
                db.Owners.Add(OwnerDetails);
                db.SaveChanges();

                return(RedirectToAction("Index", "Owner"));
            }
            catch (Exception ex)
            {
                LogFilter.Write(db, HttpContext.Request.QueryString.ToString(), HttpContext.Request.Path, HttpContext.Session.GetString("UserID"), ex);
                return(View("Error", ex));
            }
        }