public static DataTable GetListRole(DataPersistance dp, string UserName) { return(dp.OpenDataTable(string.Concat("SELECT ", dp.FormatSqlValue(false, DataType.Boolean), @" AS Pilih,RoleName AS NamaPeran FROM _System_RoleUser WHERE UserName=@0 AND ProductName=@1"), new FieldParam("0", UserName), new FieldParam("1", BaseFramework.ProductName))); }
internal static DataTable GetListRole(DataPersistance dp, bool AllRole) { dp.ValidateTableDef <Role>(); if (AllRole) { return(dp.OpenDataTable( "SELECT RoleName FROM _System_Role WHERE ProductName=@0 ORDER BY RoleName", new FieldParam("0", BaseFramework.ProductName))); } else { return(dp.OpenDataTable(string.Concat( "SELECT RoleName FROM _System_Role WHERE ProductName=@0 AND IsActive=", dp.FormatSqlValue(true, DataType.Boolean), " AND (UseDateLimit=", dp.FormatSqlValue(false, DataType.Boolean), " OR ", dp.GetSqlNow(), " BETWEEN StartDate AND EndDate) ORDER BY RoleName"), new FieldParam("0", BaseFramework.ProductName))); } }
private void TransferTable(TableDef td, string Condition) { string strWhere = Condition.Length > 0 ? " WHERE " + Condition : string.Empty; DpDestination.ValidateTableDef(td); FieldParam[] ListParam = new FieldParam[ td.KeyFields.Count + td.NonKeyFields.Count]; int paramCtr = 0; StringBuilder strFieldsDest = new StringBuilder(); StringBuilder strFieldsSource = new StringBuilder(); foreach (FieldDef fld in td.KeyFields.Values) { strFieldsDest.Append(",").Append(fld._FieldName); strFieldsSource.Append(",").Append(fld._FieldName); ListParam[paramCtr++] = new FieldParam(fld); } foreach(FieldDef fld in td.NonKeyFields.Values) { strFieldsDest.Append(",").Append(fld._FieldName); strFieldsSource.Append(",").Append(fld._FieldName); ListParam[paramCtr++] = new FieldParam(fld); } string strTemp = strFieldsDest.Remove(0, 1).ToString(); string strInsert = string.Concat("INSERT INTO ", td._TableName, "(", strTemp, ") VALUES (", strTemp.Replace(",", ",@").Insert(0, "@"), ")"); strTemp = strFieldsSource.Remove(0, 1).ToString(); DataTable dt = DpSource.OpenDataTable(string.Concat( "SELECT ", strTemp, " FROM ", td._TableName, strWhere)); int j = dt.Columns.Count; IDbCommand Cmd = DpDestination.CreateCommand(strInsert, CommandType.Text, ListParam); foreach (DataRow dr in dt.Rows) { for (int i = 0; i < j; i++) Cmd.Parameters[i] = dr[i]; Cmd.ExecuteNonQuery(); } }
public List <object[]> ShowForm(string ReturnFields, string SqlSelect, string Caption, string HideFields, params FieldParam[] Parameters) { ColNames = ReturnFields.Split(','); gridControl1.DataSource = _Dp.OpenDataTable(SqlSelect, Parameters); int Cnt = gridView1.RowCount; if (Cnt == 0) { XtraMessageBox.Show("Data Tidak Ditemukan !", "Error Membaca Data", MessageBoxButtons.OK, MessageBoxIcon.Information); return(new List <object[]>()); } Pilih = new List <bool>(Cnt); for (int i = 0; i < Cnt; i++) { Pilih.Add(false); } if (Caption.Length == 0) { Caption = "Pilih Data"; } Text = Caption; gridView1.BeginDataUpdate(); try { foreach (GridColumn gcol in gridView1.Columns) { gcol.OptionsColumn.ReadOnly = true; } if (HideFields.Length > 0) { string[] ListHideFields = HideFields.Split(','); foreach (string HideField in ListHideFields) { gridView1.Columns[HideField].Visible = false; } } GridColumn gc = gridView1.Columns.Add(); gc.FieldName = "xPilih"; gc.UnboundType = UnboundColumnType.Boolean; gc.Caption = "Pilih"; gc.AppearanceHeader.TextOptions .HAlignment = HorzAlignment.Center; gc.OptionsFilter.AllowFilter = false; gc.VisibleIndex = 0; BaseWinFramework.WinForm.AutoFormat .AutoFormatReadOnlyGridControl(gridControl1, true); gridView1.BestFitColumns(); gc.Width = 50; } finally { gridView1.EndDataUpdate(); } IsOk = false; ShowDialog(); return(IsOk ? RetVal : null); }
internal static DataTable GetListUser(DataPersistance dp) { return(dp.OpenDataTable("SELECT UserName FROM _System_User ORDER BY UserName")); }
public xDialogResult ShowForm(string SqlSelect, string Caption, string Message, xMessageBoxButtons Buttons, out bool IsDataExist, Dictionary <string, string> FormatCols, params FieldParam[] Parameters) { _Buttons = Buttons; gridControl1.DataSource = _Dp.OpenDataTable(SqlSelect, Parameters); IsDataExist = gridView1.RowCount > 0; switch (Buttons) { case SentraSolutionFramework.xMessageBoxButtons.AbortRetryIgnore: simpleButton3.Text = "Batal"; simpleButton2.Text = "Ulangi"; simpleButton1.Text = "Abaikan"; RetVal = SentraSolutionFramework.xDialogResult.Ignore; break; case SentraSolutionFramework.xMessageBoxButtons.OK: simpleButton3.Visible = false; simpleButton2.Visible = false; simpleButton1.Text = "Ok"; RetVal = SentraSolutionFramework.xDialogResult.OK; break; case SentraSolutionFramework.xMessageBoxButtons.OKCancel: simpleButton3.Visible = false; simpleButton2.Text = "Ok"; simpleButton1.Text = "Batal"; RetVal = SentraSolutionFramework.xDialogResult.Cancel; break; case SentraSolutionFramework.xMessageBoxButtons.RetryCancel: simpleButton3.Visible = false; simpleButton2.Text = "Ulangi"; simpleButton1.Text = "Batal"; RetVal = SentraSolutionFramework.xDialogResult.Cancel; break; case SentraSolutionFramework.xMessageBoxButtons.YesNo: simpleButton3.Visible = false; simpleButton2.Text = "Ya"; simpleButton1.Text = "Tidak"; RetVal = SentraSolutionFramework.xDialogResult.No; break; case SentraSolutionFramework.xMessageBoxButtons.YesNoCancel: simpleButton3.Text = "Ya"; simpleButton2.Text = "Tidak"; simpleButton1.Text = "Batal"; RetVal = SentraSolutionFramework.xDialogResult.Cancel; break; } if (!IsDataExist) { return(RetVal); } if (Caption.Length == 0) { Caption = "Daftar Data"; } Text = Caption; labelControl1.Text = Message; gridView1.BeginDataUpdate(); try { if (FormatCols != null) { foreach (KeyValuePair <string, string> FormatCol in FormatCols) { GridColumn gc = gridView1.Columns[FormatCol.Key]; if (gc != null) { gc.DisplayFormat.FormatType = FormatType.Custom; gc.DisplayFormat.FormatString = FormatCol.Value; } } } foreach (GridColumn gcol in gridView1.Columns) { gcol.OptionsColumn.ReadOnly = true; } BaseWinFramework.WinForm.AutoFormat .AutoFormatReadOnlyGridControl(gridControl1, true); gridView1.BestFitColumns(); } finally { gridView1.EndDataUpdate(); } ShowDialog(); return(RetVal); }