private void mLoadValues(ref StringBuilder sb, Subjects subject) { sb.Append(columnsStartDiv); sb.Append(string.Format("<img width='100px' height='100px' src='{0}' style='margin: 30px 0 0 30px;'></img>", mGetCoverImage(subject.pIDSubject.ToString()))); string resultValue = Farschidus.Translator.AppTranslate["general.label.na"]; List <string> valueList = new List <string>(); List <int> propertyIDs = new List <int>(); mLoadRecursivlyByParentID(ref propertyIDs, subject.pIDSubject); Properties properties = new Properties(); properties.LoadAll(); properties.Filter = string.Format("{0} IN ({1})", Properties.ColumnNames.IDProperty, string.Join(",", propertyIDs.ToArray())); if (properties.RowCount > 0) { do { SubjectPropertyValues subjectPropertyValue = new SubjectPropertyValues(subject.pIDSubject, properties.pIDProperty); if (subjectPropertyValue.RowCount > 0) { if (properties.pIDType.Equals((byte)PropertyTypes.Enum.date) && pCurrentLanguageID == 2) { resultValue = Global.MethodsAndProps.mToFarsiDigit(new Farschidus.JalaliDateTime(Convert.ToDateTime(subjectPropertyValue.pValue)).ToShortDateString()); } else if (properties.pIDType.Equals((byte)PropertyTypes.Enum.dateTime) && pCurrentLanguageID == 2) { resultValue = Global.MethodsAndProps.mToFarsiDigit(new Farschidus.JalaliDateTime(Convert.ToDateTime(subjectPropertyValue.pValue.Split(' ')[0])).ToShortDateString()); } if (properties.pIDType.Equals((byte)PropertyTypes.Enum.singleSelect)) { PropertyItems items = new PropertyItems(); items.LoadByIDProperty((int)properties.pIDProperty); items.Filter = string.Format("{0} IN ({1})", PropertyItems.ColumnNames.IDPropertyItem, subjectPropertyValue.pValue); resultValue = items.pTitle; } else { resultValue = subjectPropertyValue.pValue; } } else { resultValue = Farschidus.Translator.AppTranslate["general.label.na"]; } valueList.Add(resultValue); }while (properties.MoveNext()); foreach (string val in valueList) { //sb.Append(string.Format("{0}<br/>", val)); sb.AppendFormat("<div style='background-color: #f0f0f0; color: #3c3c3c; border-bottom: 1px solid #fff; padding: 5px;'>{0}<br/></div>", val); } } sb.Append(columnsEndDiv); }
private void mLoadListPropertyValues() { SubjectPropertyValues subjectPropertyValue = new SubjectPropertyValues(); subjectPropertyValue.LoadByIDSubject(pSubjectID); grvListPropertyValues.DataSource = subjectPropertyValue.DefaultView; grvListPropertyValues.DataBind(); uplPageList.Update(); }
protected void grvListPropertyValues_RowDeleting(object sender, GridViewDeleteEventArgs e) { int idProperty = int.Parse(grvListPropertyValues.DataKeys[Convert.ToInt32(e.RowIndex)][0].ToString()); SubjectPropertyValues subjectPropertyValues = new SubjectPropertyValues(pSubjectID, idProperty); if (subjectPropertyValues.RowCount > 0) { subjectPropertyValues.MarkAsDeleted(false); subjectPropertyValues.Save(); mLoadListPropertyValues(); mClear(); } }
private void mDelete(int iDProperty, bool loadList = true) { if (mValidateDelete(iDProperty)) { try { Properties properties = new Properties(iDProperty); PropertyItems propertyItem = new PropertyItems(); SubjectPropertyValues SubjectPropertyValue = new SubjectPropertyValues(); SubjectPropertyValue.LoadByIDProperty(iDProperty); if (SubjectPropertyValue.RowCount > 0) { SubjectPropertyValue.DeleteAll(); SubjectPropertyValue.Save(); } propertyItem.LoadByIDProperty(iDProperty); if (propertyItem.RowCount > 0) { propertyItem.DeleteAll(); propertyItem.Save(); } properties.MarkAsDeleted(false); properties.Save(); if (loadList) { pMessage.Clear(); pMessage.Add(Farschidus.Translator.AppTranslate["general.message.deleted"], Farschidus.Web.UI.Message.MessageTypes.Success); mShowMessage(pMessage); mLoadAll(); } } catch (Exception ex) { pMessage.Clear(); pMessage.Add(ex.Message, Farschidus.Web.UI.Message.MessageTypes.Error); mShowMessage(pMessage); } } mShowMessage(pMessage); }
protected void btnSave_Click(object sender, EventArgs e) { try { string result = string.Empty; int idProperty = Convert.ToInt32(ddlSubjectProperties.SelectedValue); SubjectPropertyValues subjectPropertyValue = new SubjectPropertyValues(pSubjectID, idProperty); Properties property = new Properties(idProperty); PropertyTypes.Enum selectedType = (PropertyTypes.Enum)Enum.Parse(typeof(PropertyTypes.Enum), property.pIDType.ToString()); if (subjectPropertyValue.RowCount.Equals(0)) { subjectPropertyValue.AddNew(); } switch (selectedType) { case PropertyTypes.Enum.text: { result = txtText.Text; break; } case PropertyTypes.Enum.integer: { result = txtInteger.Text; break; } case PropertyTypes.Enum.floati: { result = txtFloati.Text; break; } case PropertyTypes.Enum.singleSelect: { result = rblSingleSelect.SelectedValue; break; } case PropertyTypes.Enum.multiSelect: { foreach (GridViewRow grvRow in grvMultiSelect.Rows) { if (((CheckBox)grvRow.FindControl("chkItemsList")).Checked) { result += grvMultiSelect.DataKeys[grvRow.RowIndex][PropertyItems.ColumnNames.IDPropertyItem] + ","; } } if (!string.IsNullOrEmpty(result)) { result = result.Substring(0, result.LastIndexOf(',')); } break; } case PropertyTypes.Enum.trueFalse: { result = chbTrueFalse.Checked.ToString(); break; } case PropertyTypes.Enum.date: { if (pLanguageID == 2) { result = Farschidus.JalaliDateTime.ConvertToGregorianDate(ucJalaliDatePiker.JalaliDate).ToShortDateString(); } else { result = txtDate.Text; } break; } case PropertyTypes.Enum.time: { result = txtTime.Text; break; } case PropertyTypes.Enum.dateTime: { if (pLanguageID == 2) { result = Farschidus.JalaliDateTime.ConvertToGregorianDate(ucJalaliDatePiker.JalaliDate).ToShortDateString(); } else { result = txtDate.Text; } result += " " + txtTime.Text; break; } } if (!string.IsNullOrEmpty(result)) { subjectPropertyValue.pIDSubject = pSubjectID; subjectPropertyValue.pIDProperty = Convert.ToInt32(ddlSubjectProperties.SelectedValue); subjectPropertyValue.pValue = result; subjectPropertyValue.Save(); mLoadListPropertyValues(); mClear(); pMessage.Add(Farschidus.Translator.AppTranslate["general.message.success"], Farschidus.Web.UI.Message.MessageTypes.Success); } else { pMessage.Add(Farschidus.Translator.AppTranslate["general.message.valueNotSet"], Farschidus.Web.UI.Message.MessageTypes.Warning); } } catch (Exception ex) { pMessage.Add(ex.Message, Farschidus.Web.UI.Message.MessageTypes.Error); } finally { mShowMessage(pMessage); } }
private void mFillForm(PropertyTypes.Enum selectedType, int idProperty) { string strValue = string.Empty; SubjectPropertyValues subjectPropertyValues = new SubjectPropertyValues(pSubjectID, idProperty); if (subjectPropertyValues.RowCount > 0) { strValue = subjectPropertyValues.pValue; } switch (selectedType) { case PropertyTypes.Enum.text: { trText.Visible = true; trInteger.Visible = false; trFloati.Visible = false; trSingleSelect.Visible = false; trMultiSelect.Visible = false; trTrueFalse.Visible = false; trDate.Visible = false; trDatePe.Visible = false; trTime.Visible = false; txtText.Text = strValue; break; } case PropertyTypes.Enum.integer: { trText.Visible = false; trInteger.Visible = true; trFloati.Visible = false; trSingleSelect.Visible = false; trMultiSelect.Visible = false; trTrueFalse.Visible = false; trDate.Visible = false; trDatePe.Visible = false; trTime.Visible = false; txtInteger.Text = strValue; break; } case PropertyTypes.Enum.floati: { trText.Visible = false; trInteger.Visible = false; trFloati.Visible = true; trSingleSelect.Visible = false; trMultiSelect.Visible = false; trTrueFalse.Visible = false; trDate.Visible = false; trDatePe.Visible = false; trTime.Visible = false; txtFloati.Text = strValue; break; } case PropertyTypes.Enum.singleSelect: { trText.Visible = false; trInteger.Visible = false; trFloati.Visible = false; trSingleSelect.Visible = true; trMultiSelect.Visible = false; trTrueFalse.Visible = false; trDate.Visible = false; trDatePe.Visible = false; trTime.Visible = false; PropertyItems propertyItem = new PropertyItems(); propertyItem.LoadByIDProperty(idProperty); rblSingleSelect.DataSource = propertyItem.DefaultView; rblSingleSelect.DataTextField = PropertyItems.ColumnNames.Title; rblSingleSelect.DataValueField = PropertyItems.ColumnNames.IDPropertyItem; rblSingleSelect.DataBind(); if (!string.IsNullOrEmpty(strValue)) { rblSingleSelect.SelectedValue = strValue; } break; } case PropertyTypes.Enum.multiSelect: { trText.Visible = false; trInteger.Visible = false; trFloati.Visible = false; trSingleSelect.Visible = false; trMultiSelect.Visible = true; trTrueFalse.Visible = false; trDate.Visible = false; trDatePe.Visible = false; trTime.Visible = false; PropertyItems propertyItem = new PropertyItems(); propertyItem.LoadByIDProperty(idProperty); grvMultiSelect.DataSource = propertyItem.DefaultView; grvMultiSelect.DataBind(); if (!string.IsNullOrEmpty(strValue)) { string[] values = strValue.Split(','); foreach (string val in values) { foreach (GridViewRow grvRow in grvMultiSelect.Rows) { if (val.Equals(grvMultiSelect.DataKeys[grvRow.RowIndex][PropertyItems.ColumnNames.IDPropertyItem].ToString())) { ((CheckBox)grvRow.FindControl("chkItemsList")).Checked = true; break; } } } } break; } case PropertyTypes.Enum.trueFalse: { trText.Visible = false; trInteger.Visible = false; trFloati.Visible = false; trSingleSelect.Visible = false; trMultiSelect.Visible = false; trTrueFalse.Visible = true; trDate.Visible = false; trDatePe.Visible = false; trTime.Visible = false; if (!string.IsNullOrEmpty(strValue)) { chbTrueFalse.Checked = Convert.ToBoolean(strValue); } break; } case PropertyTypes.Enum.date: { trText.Visible = false; trInteger.Visible = false; trFloati.Visible = false; trSingleSelect.Visible = false; trMultiSelect.Visible = false; trTrueFalse.Visible = false; if (pLanguageID == 2) { trDatePe.Visible = true; trDate.Visible = false; if (!string.IsNullOrEmpty(strValue)) { ucJalaliDatePiker.JalaliDate = new Farschidus.JalaliDateTime(Convert.ToDateTime(strValue)).ToShortDateString(); } } else { trDatePe.Visible = false; trDate.Visible = true; if (!string.IsNullOrEmpty(strValue)) { txtDate.Text = strValue; } } trTime.Visible = false; break; } case PropertyTypes.Enum.time: { trText.Visible = false; trInteger.Visible = false; trFloati.Visible = false; trSingleSelect.Visible = false; trMultiSelect.Visible = false; trTrueFalse.Visible = false; trDate.Visible = false; trDatePe.Visible = false; trTime.Visible = true; txtTime.Text = strValue; break; } case PropertyTypes.Enum.dateTime: { trText.Visible = false; trInteger.Visible = false; trFloati.Visible = false; trSingleSelect.Visible = false; trMultiSelect.Visible = false; trTrueFalse.Visible = false; if (pLanguageID.Equals(2)) { trDatePe.Visible = true; trDate.Visible = false; if (!string.IsNullOrEmpty(strValue)) { ucJalaliDatePiker.JalaliDate = new Farschidus.JalaliDateTime(Convert.ToDateTime(strValue.Split(' ')[0])).ToShortDateString(); } } else { trDatePe.Visible = false; trDate.Visible = true; if (!string.IsNullOrEmpty(strValue)) { txtDate.Text = strValue.Split(' ')[0]; } } trTime.Visible = true; if (!string.IsNullOrEmpty(strValue)) { txtTime.Text = strValue.Split(' ')[1]; } break; } } uplAddEdit.Update(); }