internal void UpdateMinistries(ObservableCollection <MinistryGridViewModel> ministryList) { var addCount = 0; var updatedCount = 0; string addMessage = ""; string updatedMessage = ""; var tmpMinistryList = new List <MinistryGridViewModel>(); tmpMinistryList.AddRange(Ministries); foreach (var item in ministryList) { if (!tmpMinistryList.Exists(x => x.FullName == item.FullName)) { Ministries.Add(item); addCount++; } if (tmpMinistryList.Exists(x => x.FullName == item.FullName)) { var oldFunction = tmpMinistryList.Find(x => x.FullName == item.FullName).Function; if (oldFunction != item.Function) { tmpMinistryList.Find(x => x.FullName == item.FullName).Function = item.Function; updatedCount++; } } } if (addCount == 1) { addMessage = $"{addCount} Eintrag wurde zum Verzeichnis hinzugefügt"; } else { addMessage = $"{addCount} Einträge wurden zum Verzeichnis hinzugefügt"; } if (updatedCount == 1) { updatedMessage = $"{updatedCount} Eintrag wurde im Verzeichnis aktualisiert"; } else { updatedMessage = $"{updatedCount} Einträge wurden im Verzeichnis aktualisiert"; } MessageBox.Show(addMessage + Environment.NewLine + updatedMessage, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); //if (addCount == 1) // MessageBox.Show($"{addCount} Eintrag wurde zum Verzeichnis hinzugefügt", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); //else // MessageBox.Show($"{addCount} Einträge wurden zum Verzeichnis hinzugefügt", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); UpdateFunctionList(); MinistryViewSource.Source = Ministries; MinistryView.Refresh(); _readerWriter.WriteMinistryData(Ministries); }
public bool Contains(string category, string key) { if (category == "ministries") { return(Ministries != null && Ministries.Contains(key)); } if (category == "sectors") { return(Sectors != null && Sectors.Contains(key)); } if (category == "tags") { return(Tags != null && Tags.Contains(key)); } if (category == "services") { return(Services != null && Services.Contains(key)); } if (category == "newsletters") { return(Newsletters != null && Newsletters.Contains(key)); } if (category == "emergency") { return(Emergency != null && Emergency.Contains(key)); } return(false); }
internal void Reset() { Ministries.Clear(); MinistryViewSource.Source = Ministries; MinistryView.Refresh(); _readerWriter.WriteMinistryData(Ministries); }
public ActionResult DeleteConfirmed(int id) { Ministries ministries = db.Ministries.Find(id); db.Ministries.Remove(ministries); db.SaveChanges(); return(RedirectToAction("Admin")); }
private void OnEditRowEnd(object obj) { var item = obj as MinistryGridViewModel; if (item.ForeName == "" && item.SureName == "") { Ministries.Remove(item); } }
// GET: Ministries/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ministries ministries = db.Ministries.Find(id); if (ministries == null) { return(HttpNotFound()); } return(View(ministries)); }
public Ministries Details(int MinistryID) { Ministries ET = new Ministries(); try { SqlCon.Open(); var SqlCmd = new SqlCommand("[config].[uspReadMinistries]", SqlCon) { CommandType = CommandType.StoredProcedure }; //Insert Parameters SqlParameter pMinistryID = new SqlParameter { ParameterName = "@MinistryID", SqlDbType = SqlDbType.Int, Value = MinistryID }; SqlCmd.Parameters.Add(pMinistryID); using (var dr = SqlCmd.ExecuteReader()) { dr.Read(); if (dr.HasRows) { ET.MinistryID = Convert.ToInt32(dr["MinistryID"]); ET.Name = dr["Name"].ToString(); ET.Description = dr["Description"].ToString(); ET.ImagePath = dr["ImagePath"].ToString(); ET.ActionLink = dr["ActionLink"].ToString(); } } } catch (Exception ex) { throw ex; } if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } return(ET); }
public ActionResult Create([Bind(Include = "MinitriesID,MinistriesLeader,MinistriesPosition, MinistriesType, MinistriesDescription, LeaderImage, LogoPath")] Ministries ministries, HttpPostedFileBase file1, HttpPostedFileBase file2) { if (file1 != null) { file1.SaveAs(HttpContext.Server.MapPath("~/Content/Images/") + file1.FileName); ministries.LeaderImage = file1.FileName; } if (file2 != null) { file2.SaveAs(HttpContext.Server.MapPath("~/Content/Images/") + file2.FileName); ministries.LogoPath = file2.FileName; } db.Ministries.Add(ministries); db.SaveChanges(); return(RedirectToAction("Admin")); }
public ActionResult Edit([Bind(Include = "MinitriesID,MinistriesLeader,MinistriesPosition, MinistriesType, LeaderImage, LogoPath")] Ministries ministries, HttpPostedFileBase file1, HttpPostedFileBase file2) { if (file1 != null) { file1.SaveAs(HttpContext.Server.MapPath("~/Content/Images/") + file1.FileName); ministries.LeaderImage = file1.FileName; } if (file2 != null) { file2.SaveAs(HttpContext.Server.MapPath("~/Content/Images/") + file2.FileName); ministries.LogoPath = file2.FileName; } db.Entry(ministries).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Admin")); return(View(ministries)); }
public List <Ministries> List() { List <Ministries> List = new List <Ministries>(); try { SqlCon.Open(); var SqlCmd = new SqlCommand("[config].[uspReadMinistries]", SqlCon) { CommandType = CommandType.StoredProcedure }; using (var dr = SqlCmd.ExecuteReader()) { while (dr.Read()) { var detail = new Ministries { MinistryID = Convert.ToInt32(dr["MinistryID"]), Name = dr["Name"].ToString(), Description = dr["Description"].ToString(), ImagePath = dr["ImagePath"].ToString(), ActionLink = dr["ActionLink"].ToString(), ActiveFlag = Convert.ToBoolean(dr["ActiveFlag"]) }; List.Add(detail); } } } catch (Exception ex) { throw ex; } if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } return(List); }
public bool Any() { return((Ministries?.Any() ?? false) || (Sectors?.Any() ?? false) || (Tags?.Any() ?? false) || (Services?.Any() ?? false) || (Newsletters?.Any() ?? false) || (Emergency?.Any() ?? false)); }
public bool AddNew(Ministries Ministry, string InsertUser) { bool rpta = false; try { SqlCon.Open(); var SqlCmd = new SqlCommand("[adm].[uspAddMinistry]", SqlCon) { CommandType = CommandType.StoredProcedure }; //Insert Parameters SqlParameter Title = new SqlParameter { ParameterName = "@Name", SqlDbType = SqlDbType.VarChar, Size = 50, Value = Ministry.Name.Trim() }; SqlCmd.Parameters.Add(Title); SqlParameter Description = new SqlParameter { ParameterName = "@Description", SqlDbType = SqlDbType.VarChar, Value = Ministry.Description.Trim() }; SqlCmd.Parameters.Add(Description); SqlParameter pImage = new SqlParameter { ParameterName = "@Image", SqlDbType = SqlDbType.VarChar, Size = 500, Value = Ministry.ImagePath }; SqlCmd.Parameters.Add(pImage); SqlParameter Link = new SqlParameter { ParameterName = "@ActionLink", SqlDbType = SqlDbType.VarChar, Size = 50, Value = Ministry.ActionLink }; SqlCmd.Parameters.Add(Link); SqlParameter ParInsertUser = new SqlParameter { ParameterName = "@InsertUser", SqlDbType = SqlDbType.VarChar, Size = 50, Value = InsertUser }; SqlCmd.Parameters.Add(ParInsertUser); //Exec Command SqlCmd.ExecuteNonQuery(); rpta = true; } catch (Exception ex) { throw ex; } if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } return(rpta); }
public bool Update(Ministries Event, string InsertUser) { bool rpta = false; try { SqlCon.Open(); var SqlCmd = new SqlCommand("[adm].[uspUpdateMinistry]", SqlCon) { CommandType = CommandType.StoredProcedure }; //Insert Parameters SqlParameter EventID = new SqlParameter { ParameterName = "@MinistryID", SqlDbType = SqlDbType.Int, Value = Event.MinistryID }; SqlCmd.Parameters.Add(EventID); SqlParameter Name = new SqlParameter { ParameterName = "@Name", SqlDbType = SqlDbType.VarChar, Size = 50, Value = Event.Name }; SqlCmd.Parameters.Add(Name); SqlParameter Description = new SqlParameter { ParameterName = "@Description", SqlDbType = SqlDbType.VarChar, Value = Event.Description }; SqlCmd.Parameters.Add(Description); SqlParameter pImage = new SqlParameter { ParameterName = "@Image", SqlDbType = SqlDbType.VarChar, Size = 500, Value = Event.ImagePath }; SqlCmd.Parameters.Add(pImage); SqlParameter Actionlink = new SqlParameter { ParameterName = "@ActionLink", SqlDbType = SqlDbType.VarChar, Value = Event.ActionLink }; SqlCmd.Parameters.Add(Actionlink); SqlParameter ParInsertUser = new SqlParameter { ParameterName = "@InsertUser", SqlDbType = SqlDbType.VarChar, Size = 50, Value = InsertUser }; SqlCmd.Parameters.Add(ParInsertUser); SqlParameter UpdateType = new SqlParameter { ParameterName = "@UpdateType", SqlDbType = SqlDbType.VarChar, Size = 10, Value = Event.ActionType }; SqlCmd.Parameters.Add(UpdateType); //Exec Command SqlCmd.ExecuteNonQuery(); rpta = true; } catch (Exception ex) { throw ex; } if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } return(rpta); }
public bool Update(Ministries ministry, string insertuser) { return(MDAL.Update(ministry, insertuser)); }
public bool AddNew(Ministries min, string insertuser) { return(MDAL.AddNew(min, insertuser)); }