//************************************************************************** /// <Description> /// This method use to save data to data base /// </Description> /// <Inputs> /// /// </Inputs> /// <Outputs> /// bool /// </Outputs> /// <Returns> /// true if successful, false if failed /// </Returns> /// <Authors> /// DungLA /// </Authors> /// <History> /// 03-Feb-2005 /// </History> /// <Notes> /// </Notes> //************************************************************************** private bool SaveData() { bool blnIsOK = false; try { switch (mEnumType) { case EnumAction.Edit: // prepare data for VO object string strOldID = mReportGroup.GroupID; mReportGroup.GroupID = txtGroupCode.Text.Trim(); mReportGroup.GroupName = txtGroupName.Text.Trim(); // update object to database boReportGroup.Update(mReportGroup, strOldID); mGroupID = mReportGroup.GroupID; mGroupName = mReportGroup.GroupName; mGroupOrder = mReportGroup.GroupOrder; blnIsOK = true; break; case EnumAction.Add: case EnumAction.Copy: mReportGroup = new sys_ReportGroupVO(); // prepare data for VO object mReportGroup.GroupID = txtGroupCode.Text.Trim(); mReportGroup.GroupName = txtGroupName.Text.Trim(); // new group order = current max order + 1 mReportGroup.GroupOrder = boReportGroup.GetMaxGroupOrder() + 1; // add new object to database boReportGroup.Add(mReportGroup); mGroupID = mReportGroup.GroupID; mGroupName = mReportGroup.GroupName; mGroupOrder = mReportGroup.GroupOrder; blnIsOK = true; break; } } catch (PCSException ex) { throw ex; } catch (Exception ex) { throw ex; } return(blnIsOK); }
public ArrayList GetAllGroups() { sys_ReportGroupDS dsReportGroup = new sys_ReportGroupDS(); sys_ReportGroupVO voReportGroup; ArrayList arrGroups = new ArrayList(); DataSet dset = new DataSet(); dset = dsReportGroup.List(); foreach (DataRow row in dset.Tables[0].Rows) { voReportGroup = new sys_ReportGroupVO(); voReportGroup.GroupID = row[sys_ReportGroupTable.GROUPID_FLD].ToString(); voReportGroup.GroupName = row[sys_ReportGroupTable.GROUPNAME_FLD].ToString(); voReportGroup.GroupOrder = int.Parse(row[sys_ReportGroupTable.GROUPORDER_FLD].ToString()); // add object sys_ReportGroupVO into array arrGroups.Add(voReportGroup); } return(arrGroups); }
public bool MoveDownGroup(string pstrGroupID) { const string METHOD_NAME = THIS + ".MoveDownGroup()"; bool blnResult = true; sys_ReportGroupDS dsReportGroup = new sys_ReportGroupDS(); sys_ReportGroupVO voPreviousGroup = new sys_ReportGroupVO(); sys_ReportGroupVO voCurrentGroup = new sys_ReportGroupVO(); ArrayList arrGroups = new ArrayList(); arrGroups = dsReportGroup.GetObjectVOs(); for (int i = 0; i < arrGroups.Count; i++) { sys_ReportGroupVO voReportGroup = (sys_ReportGroupVO)arrGroups[i]; string strGroupID = voReportGroup.GroupID; if (strGroupID.Equals(pstrGroupID)) { int intCurGroupOrder = voReportGroup.GroupOrder; // if current order reached the bottom of layout then return false if (intCurGroupOrder >= arrGroups.Count) { blnResult = false; } else { // get the previous group voPreviousGroup = (sys_ReportGroupVO)arrGroups[i + 1]; // get the current group voCurrentGroup = (sys_ReportGroupVO)arrGroups[i]; // switch order voCurrentGroup.GroupOrder = voPreviousGroup.GroupOrder; voPreviousGroup.GroupOrder = intCurGroupOrder; //update two rows into database dsReportGroup.Update(voPreviousGroup); dsReportGroup.Update(voCurrentGroup); blnResult = true; } } } return(blnResult); }
public bool MoveUpGroup(string pstrGroupID) { bool blnResult = true; sys_ReportGroupDS dsReportGroup = new sys_ReportGroupDS(); sys_ReportGroupVO voPreviousGroup = new sys_ReportGroupVO(); sys_ReportGroupVO voCurrentGroup = new sys_ReportGroupVO(); ArrayList arrGroups = new ArrayList(); arrGroups = dsReportGroup.GetObjectVOs(); for (int i = 0; i < arrGroups.Count; i++) { sys_ReportGroupVO voReportGroup = (sys_ReportGroupVO)arrGroups[i]; string strGroupID = voReportGroup.GroupID; if (strGroupID.Equals(pstrGroupID)) { int intCurrentOrder = voReportGroup.GroupOrder; // if current order reached the top of layout then return false if (intCurrentOrder <= 1) { blnResult = false; } else { // get previous group voPreviousGroup = (sys_ReportGroupVO)arrGroups[i - 1]; // get current group voCurrentGroup = (sys_ReportGroupVO)arrGroups[i]; // switch order between two groups voCurrentGroup.GroupOrder = voPreviousGroup.GroupOrder; voPreviousGroup.GroupOrder = intCurrentOrder; //update two rows into database dsReportGroup.Update(voPreviousGroup); dsReportGroup.Update(voCurrentGroup); blnResult = true; } } } return(blnResult); }
private void ReportGroup_Closing(object sender, System.ComponentModel.CancelEventArgs e) { const string METHOD_NAME = THIS + ".ReportGroup_Closing()"; try { if (mEnumType != EnumAction.Default) { // txtGroupCode.ModiModified //txtGroupCode.Text != string.Empty || // if (txtGroupName.Modified || // txtGroupName.Text != string.Empty) if (txtGroupName.Text != string.Empty) { if (txtGroupName.Modified) { // display confirm message DialogResult dlgResult = PCSMessageBox.Show(ErrorCode.MESSAGE_QUESTION_STORE_INTO_DATABASE, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); switch (dlgResult) { case DialogResult.Cancel: e.Cancel = true; break; case DialogResult.Yes: try { // save data before close the form if (!SaveData()) { e.Cancel = true; } else { e.Cancel = false; } } catch { e.Cancel = true; } break; case DialogResult.No: mReportGroup = new sys_ReportGroupVO(); break; } } } } } catch (PCSException ex) { // displays the error message. PCSMessageBox.Show(ex.mCode, MessageBoxButtons.OK, MessageBoxIcon.Error); // log message. try { Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR); } catch { PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { // displays the error message. PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); // log message. try { Logger.LogMessage(ex, METHOD_NAME, Level.ERROR); } catch { PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }