protected void updateComplexPicButton_Click(object sender, EventArgs e) { if (!this.ValidateFields(8)) { return; } this.complexHiddenUp.Value = this.removeUpdatePicSelector.SelectedValue.Remove(0, 1); ComplexRoomPic p = (ComplexRoomPic)this.Master._PapaDal.Get("complexPic", this.complexHiddenUp.Value); if (p == null) { this.Master._Logger.Error(new AdminException (". p == null"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(0, "Red", "")); return; } if (p.PicBWFullPath != null) { if (p.PicBWFullPath != "") { this.complexHiddenType.Value = p.PicBWFullPath; } } this.UpdatePicInit(); this.DivSwitcher(2); }
private void EnablePic() { if (!this.ValidateFields(5)) { this.ClearFields(3); return; } ComplexRoomPic p = (ComplexRoomPic)this.Master._PapaDal.Get("complexPic", this.complexHiddenUp.Value); if (p == null) { this.Master._Logger.Error(new AdminException (". p == null"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(0, "Red", "")); this.ClearFields(3); return; } if (p.Active == 1) { this.Master._Logger.Warn(new AdminException (". " + this.complexHiddenUp.Value + " Is Already Disabled"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(9, "Red", p.RoomTitleHe)); this.ClearFields(3); return; } if (!this.Master._PapaDal.CheckPlacesStatus(p.RoomName)) { this.Master._Logger.Warn(new AdminException (". Max Pictures For " + p.RoomName), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(54, "Red", p.RoomName)); this.ClearFields(3); return; } try { this.Master._PapaDal.Enable("complexPic", p.RoomTitleHe); this.Master._Logger.Log(new AdminException(". " + p.RoomTitleHe + " Has Been Successfully Enabled"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(6, "White", p.RoomTitleHe)); } catch (Exception f) { this.Master._Logger.Log(f, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(10, "Red", p.RoomTitleHe)); } }
private void RemovePic() { if (!this.ValidateFields(4)) { this.ClearFields(3); return; } ComplexRoomPic p = (ComplexRoomPic)this.Master._PapaDal.Get("complexPic", this.complexHiddenRe.Value); if (p == null) { this.Master._Logger.Error(new AdminException (". p == null"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(0, "Red", "")); this.ClearFields(3); return; } try { if (File.Exists(p.PicBWFullPath)) { File.Delete(p.PicBWFullPath); } if (File.Exists(p.PicColorFullPath)) { File.Delete(p.PicColorFullPath); } this.Master._PapaDal.Remove("complexPic", this.complexHiddenRe.Value); this.Master._Logger.Log(new AdminException(". " + p.RoomTitleHe + " Was Successfully Removed"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(12, "White", p.RoomTitleHe)); this.removeUpdatePicSelector.Items.Remove (this.removeUpdatePicSelector.Items.FindByValue( "s" + this.complexHiddenRe.Value)); } catch (Exception e) { this.Master._Logger.Log(e, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(13, "Red", p.RoomTitleHe)); } }
private void UpdatePic() { if (!this.ValidateFields(2)) { this.ClearComplexPic(); return; } if (!this.ValidateFields(8)) { this.ClearComplexPic(); return; } if (this.complexBWPicUpload.Value == "" && this.complexPicTypeSelector.SelectedIndex == 4) { this.Master._Logger.Error(new AdminException (". this.complexBWPicUpload.Value == \"\""), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(37, "Red", "Black And White Complex Pic")); this.ClearComplexPic(); this.ShowBWArea(false); return; } ComplexRoomPic p = (ComplexRoomPic)this.Master._PapaDal.Get("complexPic", this.complexHiddenUp.Value); if (p == null) { this.Master._Logger.Error(new AdminException (". p == null"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(0, "Red", "")); this.ClearComplexPic(); return; } if (!this.Master._PapaDal.CheckAvailablePlaceExcept(this.complexPicTypeSelector.SelectedValue, p.PicPlace, int.Parse(this.complexPicPlaceSelector.SelectedValue))) { this.Master._Logger.Error(new AdminException (@". (!this.Master._PapaDal.CheckAvailablePlaceExcept(this.complexPicTypeSelector.SelectedValue, p.PicPlace, int.Parse(this.complexPicPlace.Text)))"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(21, "Red", this.complexPicPlaceSelector.SelectedValue)); this.ClearComplexPic(); return; } if (this.complexColorPicUpload.Value != "") { if (!this.Master._GlobalFunctions.ValidatePicEnd(this.complexColorPicUpload.Value)) { this.Master._Logger.Error(new AdminException (". !this.Master._GlobalFunctions.ValidatePicEnd(this.complexColorPicUpload.Value)"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(14, "Red", this.complexColorPicUpload.Value)); this.ClearComplexPic(); return; } string fileColorName = this.complexColorPicUpload.PostedFile.FileName; string fileColorNameToSave = "complexColorPic_id-" + p.PicID + "_" + fileColorName; string fullColorPath = this.Master._GlobalFunctions.GetFullPath() + fileColorNameToSave; string relativeColorPath = this.Master._GlobalFunctions.GetRelativePath() + fileColorNameToSave; try { if (File.Exists(p.PicColorFullPath)) { File.Delete(p.PicColorFullPath); } this.complexColorPicUpload.PostedFile.SaveAs(fullColorPath); p.PicColorFullPath = fullColorPath; p.PicColorRelativePath = relativeColorPath; } catch (Exception f) { this.Master._Logger.Error(f, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(36, "Red", this.complexColorPicUpload.Value)); this.ClearComplexPic(); return; } } if (this.complexBWPicUpload.Value != "") { if (!this.Master._GlobalFunctions.ValidatePicEnd(this.complexBWPicUpload.Value)) { this.Master._Logger.Error(new AdminException (". !this.Master._GlobalFunctions.ValidatePicEnd(this.complexBWPicUpload.Value)"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(14, "Red", p.RoomTitleHe)); this.ClearComplexPic(); return; } string fileBWName = this.complexBWPicUpload.PostedFile.FileName; string fileBWNameToSave = "complexBWPic_id-" + p.PicID + "_" + fileBWName; string fullBWPath = this.Master._GlobalFunctions.GetFullPath() + fileBWNameToSave; string relativeBWPath = this.Master._GlobalFunctions.GetRelativePath() + fileBWNameToSave; try { if (File.Exists(p.PicBWFullPath)) { File.Delete(p.PicBWFullPath); } this.complexBWPicUpload.PostedFile.SaveAs(fullBWPath); p.PicBWFullPath = fullBWPath; p.PicBWRelativePath = relativeBWPath; } catch (Exception f) { this.Master._Logger.Error(f, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(36, "Red", this.complexBWPicUpload.Value)); this.ClearComplexPic(); return; } } else { if (File.Exists(p.PicBWFullPath)) { File.Delete(p.PicBWFullPath); } p.PicBWFullPath = ""; p.PicBWRelativePath = ""; } try { p.spLastUpdate = TimeNow.TheTimeNow.ToShortDateString(); p.LastUpdate = TimeNow.TheTimeNow; p.RoomName = this.complexPicTypeSelector.SelectedValue; p.PicPlace = int.Parse(this.complexPicPlaceSelector.SelectedValue); p.RoomTitleHe = this.complexTitleRoomHe.Text; p.RoomTitleEn = this.complexTitleRoomEn.Text; p.RoomTextHe = this.complexAboutRoomHe.Text; p.RoomTextEn = this.complexTitleRoomEn.Text; this.Master._PapaDal.Update("complexPic", p, TimeNow.TheTimeNow); this.Master._Logger.Log(new AdminException(". " + p.PicID + " Was Successfully Updated"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(17, "White", p.RoomTitleHe)); this.removeUpdatePicSelector.Items.FindByValue("s" + p.PicID).Text = p.RoomTitleHe; } catch (Exception e) { this.Master._Logger.Log(e, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(18, "Red", p.RoomTitleHe)); } }
private void UpdatePicInit() { if (!this.ValidateFields(5)) { this.ClearComplexPic(); return; } ComplexRoomPic p = (ComplexRoomPic)this.Master._PapaDal.Get("complexPic", this.complexHiddenUp.Value); if (p == null) { this.Master._Logger.Error(new AdminException (". p == null"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(0, "Red", "")); this.ClearComplexPic(); return; } if (p.RoomName == "complexWhoPlaysHere") { this.SetPicPlaceSelector("who", "update"); } else { this.SetPicPlaceSelector("notWho", "none"); } foreach (ListItem l in this.complexPicTypeSelector.Items) { l.Selected = false; } try { this.complexPicStatusLabel.Text = p.spActive; this.complexPicLastUpdateLabel.Text = p.spLastUpdate; this.complexPicTypeSelector.Items.FindByValue(p.RoomName).Selected = true; this.complexPicPlaceSelector.SelectedValue = p.PicPlace.ToString(); this.complexTitleRoomHe.Text = p.RoomTitleHe; this.complexTitleRoomEn.Text = p.RoomTitleEn; this.complexAboutRoomHe.Text = p.RoomTextHe; this.complexAboutRoomEn.Text = p.RoomTextEn; this.complexColorPicUploadPic.Src = p.PicColorRelativePath; this.ShowColorPic(true); this.ShowColorFile(true); if (p.PicBWFullPath != null) { if (p.PicBWFullPath != "") { this.complexBWPicUploadPic.Src = p.PicBWRelativePath; this.ShowBWPic(true); this.ShowBWFile(true); } } } catch (Exception t) { this.Master._Logger.Error(t, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(0, "Red", "")); this.ClearComplexPic(); } }
private void AddComplexPic() { if (!this.ValidateFields(2)) { this.ClearComplexPic(); return; } if (this.complexColorPicUpload.Value == "") { this.Master._Logger.Error(new AdminException (". this.complexColorPicUpload.Value == \"\""), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(37, "Red", "Complex Color")); return; } string ID = this.Master._PapaDal.GetNextAvailableID("complexPic"); string fileColorName = this.complexColorPicUpload.PostedFile.FileName; string fileColorNameToSave = "complexColorPic_id-" + ID + "_" + fileColorName; string fullColorPath = this.Master._GlobalFunctions.GetFullPath() + fileColorNameToSave; string relativeColorPath = this.Master._GlobalFunctions.GetRelativePath() + fileColorNameToSave; string fileBWName = ""; string fileBWNameToSave = ""; string fullBWPath = ""; string relativeBWPath = ""; if (!this.Master._PapaDal.CheckAvailablePlace(this.complexPicTypeSelector.SelectedValue, int.Parse(this.complexPicPlaceSelector.SelectedValue))) { this.Master._Logger.Error(new AdminException (@". (!this.Master._PapaDal.CheckAvailablePlace(this.complexPicTypeSelector.SelectedValue, int.Parse(this.complexPicPlaceSelector.SelectedValue)))"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(21, "Red", this.complexPicPlaceSelector.SelectedValue)); this.ClearComplexPic(); return; } if (this.complexPicTypeSelector.SelectedIndex == 4 && this.complexBWPicUpload.Value == "") { this.Master._Logger.Error(new AdminException (". this.complexBWPicUpload.Value == \"\""), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(37, "Red", "Black And White Complex Picture")); return; } else { if (!this.Master._GlobalFunctions.ValidatePicEnd(this.complexBWPicUpload.Value)) { this.Master._Logger.Error(new AdminException (". !this.Master._GlobalFunctions.ValidatePicEnd(this.complexBWPicUpload.Value)"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(14, "Red", this.complexBWPicUpload.Value)); this.ClearComplexPic(); return; } fileBWName = this.complexBWPicUpload.PostedFile.FileName; fileBWNameToSave = "complexBWPic_id-" + ID + "_" + fileBWName; fullBWPath = this.Master._GlobalFunctions.GetFullPath() + fileBWNameToSave; relativeBWPath = this.Master._GlobalFunctions.GetRelativePath() + fileBWNameToSave; if (!this.Master._GlobalFunctions.ValidatePicEnd(this.complexColorPicUpload.Value)) { this.Master._Logger.Error(new AdminException (". !this.Master._GlobalFunctions.ValidatePicEnd(this.complexColorPicUpload.Value)"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(14, "Red", this.complexColorPicUpload.Value)); this.ClearComplexPic(); return; } } if (this.complexBWPicUpload.Value != "") { try { this.complexBWPicUpload.PostedFile.SaveAs(fullBWPath); } catch (Exception t) { this.Master._Logger.Error(t, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(36, "Red", this.complexBWPicUpload.Value)); this.ClearComplexPic(); return; } } try { this.complexColorPicUpload.PostedFile.SaveAs(fullColorPath); } catch (Exception o) { this.Master._Logger.Error(o, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(36, "Red", this.complexColorPicUpload.Value)); this.ClearComplexPic(); return; } string title = ""; string room = ""; try { room = this.Master._GlobalFunctions.ConvertToUtf8(this.complexAboutRoomHe.Text); title = this.Master._GlobalFunctions.ConvertToUtf8(this.complexTitleRoomHe.Text); ComplexRoomPic p = new ComplexRoomPic { Active = 2, PicPlace = int.Parse(this.complexPicPlaceSelector.SelectedValue), RoomName = this.complexPicTypeSelector.SelectedValue, RoomTextEn = this.complexAboutRoomEn.Text, RoomTextHe = room, RoomTitleEn = this.complexTitleRoomEn.Text, RoomTitleHe = title, PicID = ID, PicBWFullPath = fullBWPath, PicBWRelativePath = relativeBWPath, PicColorFullPath = fullColorPath, PicColorRelativePath = relativeColorPath, LastUpdate = TimeNow.TheTimeNow, spLastUpdate = TimeNow.TheTimeNow.ToShortDateString(), UploadTime = TimeNow.TheTimeNow, spUploadTime = TimeNow.TheTimeNow.ToString(), spActive = "Disable" }; this.Master._PapaDal.Add("complexPic", p); this.Master._Logger.Log(new AdminException(". " + p.PicID + " Was Successfully Added"), MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(15, "White", p.RoomTitleHe)); this.removeUpdatePicSelector.Items.Add(new ListItem(p.RoomTitleHe, "s" + ID)); } catch (Exception e) { this.Master._Logger.Error(e, MethodBase.GetCurrentMethod().Name); this.Notify(this.Master._Notifier.Notify(16, "Red", fileBWName + " And " + fileColorName)); } }