Example #1
0
        void bindingExpressionEditor(int iExpressionType, string CalaculatedColumnValue = "", string strColname = "")
        {
            try
            {
                clsDataSource   clsObj   = new clsDataSource();
                DataTable       dtSource = clsObj.fnGetColMappingData(Common.iProjectID);
                DataTable       dt       = clsDSOBJ.fnGetTreDetails(Common.strTableName);
                DataTableReader dr       = new DataTableReader(dt);
                DataTable       dtSchema = dr.GetSchemaTable();

                string strExpression = "";
                if (iExpressionType == (int)Enums.ExpressionType.Filter)
                {
                    strExpression = clsObj.fnselectFilterCondition(Common.iProjectID);
                }
                else
                {
                    strExpression = "";
                }
                if (iExpressionType == (int)Enums.ExpressionType.CalaculatedColumn)
                {
                    strExpression = CalaculatedColumnValue;
                }
                using (var frm = new frmExpressEditor(iExpressionType, Common.strTableName, strExpression))
                {
                    frm._fieldDict      = Common.GetDict(dt);
                    frm.AvailableFields = frm._fieldDict.ToList <KeyValuePair <string, Type> >();
                    frm.dtSource        = dtSchema;
                    var res = frm.ShowDialog();
                    if (res == System.Windows.Forms.DialogResult.OK)
                    {
                        if (iExpressionType == (int)Enums.ExpressionType.Filter)
                        {
                            clsObj.fnInserFilter(frm.strExpression, Common.iProjectID);
                        }
                        else if (iExpressionType == (int)Enums.ExpressionType.AddColumn)
                        {
                            //  Common.strfiltertxt = "";
                            string strColName = frm.strColName;

                            string strMsg = "";
                            strExpression = frm.strExpression;
                            if (!clsObj.fnAddCalaculatedColumn(Common.strTableName, strColName, strExpression, ref strMsg, Common.iProjectID))
                            {
                                if (strMsg != "")
                                {
                                    Telerik.WinControls.RadMessageBox.Show(this, strMsg, "Information", MessageBoxButtons.OK, RadMessageIcon.Error, MessageBoxDefaultButton.Button1);
                                }
                                return;
                            }
                        }
                        else if (iExpressionType == (int)Enums.ExpressionType.CalaculatedColumn)
                        {
                            if (!clsObj.fnUpdateCalaculatedColumn(Common.strTableName, strColname, frm.strExpression, Common.iProjectID))
                            {
                            }
                        }
                        dtmain = (DataTable)dataschemaGrid.DataSource;
                        dataschemaGridbinding();
                    }
                }
            }
            catch (Exception ex)
            {
                Telerik.WinControls.RadMessageBox.Show(this, ex.Message, ex.TargetSite.Name.ToString(), MessageBoxButtons.OK, RadMessageIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }