Exemple #1
0
        private void fnFillSource()
        {
            try
            {
                clsDataSource clsObj   = new clsDataSource();
                DataTable     dtSource = clsObj.fnGetColMappingData(Common.iProjectID);
                DataRow[]     dr       = dtSource.Select("TYPE=" + ((int)Enums.ColType.Input).ToString() + " And ISREQUIRED=1");

                DataTable dt = dr.CopyToDataTable();

                ddlSource.DataSource    = dt;
                ddlSource.ValueMember   = "COLNAME";
                ddlSource.DisplayMember = "COLNAME";

                ddlSource.SelectedIndex = 0;
                foreach (string opptype in OpportunityTypes)
                {
                    ddlOpportunityType.Items.Add(opptype);
                }
                ddlOpportunityType.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        private void pctFormula_Click(object sender, EventArgs e)
        {
            try
            {
                clsDataSource clsObj = new clsDataSource();
                // frmExpressEditor frm = new frmExpressEditor();
                DataTable dtSource = clsObj.fnGetColMappingData();

                DataTable dt = new DataTable();

                for (int i = 0; i < dtSource.Rows.Count; i++)
                {
                    if ((dtSource.Rows[i]["TYPE"].ToString() == ((int)Enums.ColType.Key).ToString()) ||
                        (dtSource.Rows[i]["TYPE"].ToString() == ((int)Enums.ColType.Input).ToString() && dtSource.Rows[i]["ISREQUIRED"].ToString() == "1"))
                    {
                        if (dtSource.Rows[i]["COLDATATYPE"].ToString().ToUpper() == "System.Decimal".ToUpper())
                        {
                            dt.Columns.Add(new DataColumn(dtSource.Rows[i]["COLNAME"].ToString(), typeof(decimal)));
                        }
                        else if (dtSource.Rows[i]["COLDATATYPE"].ToString().ToUpper() == "System.DateTime".ToUpper())
                        {
                            dt.Columns.Add(new DataColumn(dtSource.Rows[i]["COLNAME"].ToString(), typeof(DateTime)));
                        }
                        else if (dtSource.Rows[i]["COLDATATYPE"].ToString().ToUpper() == "System.String".ToUpper())
                        {
                            dt.Columns.Add(new DataColumn(dtSource.Rows[i]["COLNAME"].ToString(), typeof(string)));
                        }
                        else if (dtSource.Rows[i]["COLDATATYPE"].ToString().ToUpper() == "System.int".ToUpper() ||
                                 dtSource.Rows[i]["COLDATATYPE"].ToString().ToUpper() == "System.Int16".ToUpper() ||
                                 dtSource.Rows[i]["COLDATATYPE"].ToString().ToUpper() == "System.Int32".ToUpper() ||
                                 dtSource.Rows[i]["COLDATATYPE"].ToString().ToUpper() == "System.Int64".ToUpper())
                        {
                            dt.Columns.Add(new DataColumn(dtSource.Rows[i]["COLNAME"].ToString(), typeof(int)));
                        }
                    }
                }


                dt.Columns.Add(new DataColumn("OPPValue", typeof(decimal)));


                using (var frm = new frmExpressEditor((int)Enums.ExpressionType.Opp_ptnl, Common.strTableName, strExpression))
                {
                    frm._fieldDict      = GetDict(dt);
                    frm.AvailableFields = frm._fieldDict.ToList <KeyValuePair <string, Type> >();
                    frm.dtSource        = dtSource;
                    var res = frm.ShowDialog();
                    if (res == System.Windows.Forms.DialogResult.OK)
                    {
                        strExpression = frm.strExpression;
                    }
                }
            }
            catch (Exception ex)
            {
                Telerik.WinControls.RadMessageBox.Show(this, ex.Message, ex.TargetSite.Name.ToString(), MessageBoxButtons.OK, RadMessageIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Exemple #3
0
        private void fnIsTableMapped()
        {
            DataTable dt = clsObj.fnGetColMappingData(Common.iProjectID);

            if (dt.Rows.Count == 0)
            {
                Common.strTableName = "";
                fnDisableControls(false, true);
            }
            else
            {
                Common.strTableName = dt.Rows[0]["TableName"].ToString();

                DataRow[] drRow = dt.Select("TYPE=" + (int)Enums.ColType.Key);
                if (drRow.Length > 0)
                {
                    Common.strKeyName = drRow[0]["COLNAME"].ToString();
                }
                Common.SetLoginDetailsToRegistry();
            }
        }
        void dataschemaGridbinding()
        {
            try
            {
                DataTable dt            = clsDSOBJ.fnGetTreDetailsSchema(ddlTableName.SelectedValue.ToString());
                DataTable dtcalaculated = clsDSOBJ.fnGetCalaculatedColMappingData(Common.iProjectID, Common.strTableName);
                DataTable dt1           = clsDSOBJ.fnGetColMappingData(Common.iProjectID);
                DataRow   row;

                dt.Columns.Add(new DataColumn("Table", typeof(string)));
                dt.Columns.Add(new DataColumn("Type", typeof(int)));
                dt.Columns.Add(new DataColumn("Required", typeof(bool)));
                foreach (DataRow drcal in dtcalaculated.Rows)
                {
                    row = dt.NewRow();
                    row["ColumnName"] = drcal["COLNAME"].ToString();
                    row["Table"]      = "C";
                    //if (drcal["COLDATATYPE"].ToString() == "NUMBER")
                    //{
                    //    row["DataType"] = typeof(decimal);
                    //}
                    row["DataType"] = drcal["COLDATATYPE"].ToString() == "NUMBER" ? typeof(Decimal) : drcal["COLDATATYPE"].ToString() == "DATE" ? typeof(DateTime) : typeof(String);
                    dt.Rows.Add(row);
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt1.Rows.Count > 0)
                    {
                        DataRow[] dr = dt1.Select("COLNAME='" + dt.Rows[i][0].ToString() + "'");
                        if (dr.Length > 0 && dr[0]["TABLENAME"].ToString().ToLower() == ddlTableName.SelectedValue.ToString().ToLower())
                        {
                            dt.Rows[i]["Type"]     = dr[0]["Type"];
                            dt.Rows[i]["Required"] = dr[0]["ISREQUIRED"];
                            if (dt.Rows[i]["Table"].ToString() != "C")
                            {
                                dt.Rows[i]["Table"] = "M";
                            }
                        }
                        else
                        {
                            dt.Rows[i]["Type"] = (int)Enums.ColType.None;
                            if (dt.Rows[i]["Table"] != "C")
                            {
                                dt.Rows[i]["Table"] = "M";
                            }
                            dt.Rows[i]["Required"] = false;
                        }
                    }
                    else
                    {
                        dt.Rows[i]["Type"] = (int)Enums.ColType.None;
                        if (dt.Rows[i]["Table"] != "C")
                        {
                            dt.Rows[i]["Table"] = "M";
                        }
                        dt.Rows[i]["Required"] = false;
                    }
                }

                dataschemaGrid.DataSource = dt;
                ////   DataTable dtmain = (DataTable)dataschemaGrid.DataSource;
                //   if (dtmain.Rows.Count > 0)
                //   {
                //       //dtmain.Merge(dt, true);
                //       if (dtmain.Rows.Count != dt.Rows.Count)
                //       {
                //           DataRow dr = dtmain.NewRow();
                //         dr = dt.Rows[dt.Rows.Count - 1] as DataRow;
                //           dt.Rows[dt.Rows.Count - 1].Delete();
                //           dtmain.Rows.Add(dr.ItemArray);
                //           dataschemaGrid.DataSource = dtmain;
                //           dtmain = null;
                //       }
                //   }
                //   else
                //   {
                //       dataschemaGrid.DataSource = dt;
                //   }
                GridViewComboBoxColumn categoryColumn = new GridViewComboBoxColumn();
                categoryColumn.HeaderText    = "Type";
                categoryColumn.ValueMember   = "TypeId";
                categoryColumn.DisplayMember = "Type";
                categoryColumn.FieldName     = "Type";
                categoryColumn.DataSource    = clsDSOBJ.fnCreateColTypes();
                categoryColumn.Width         = 200;
                if (dataschemaGrid.MasterTemplate.Columns.Contains("Type1"))
                {
                    dataschemaGrid.MasterTemplate.Columns.Remove("Type1");
                }
                dataschemaGrid.MasterTemplate.Columns.Add(categoryColumn);
                dataschemaGrid.Columns["ColumnName"].ReadOnly = true;
                dataschemaGrid.Columns["DataType"].ReadOnly   = true;
                dataschemaGrid.Columns["Type"].ReadOnly       = true;
                dataschemaGrid.Columns["Type"].IsVisible      = false;
                dataschemaGrid.Columns["Table"].IsVisible     = true;
                dataschemaGrid.Columns[0].Width = 200;
                // dataschemaGrid.Columns[1].AutoSizeMode = BestFitColumnMode.DisplayedDataCells;
                dataschemaGrid.Columns["DataType"].Width = 300;
                dataschemaGrid.Columns["Required"].Width = 50;
                dataschemaGrid.Columns["Table"].Width    = 30;
                dataschemaGrid.Columns.Remove("NumericPrecision");
                dataschemaGrid.Columns.Remove("NumericScale");
                dataschemaGrid.Columns.Remove("ProviderType");
                dataschemaGrid.Columns.Remove("IsLong");
                dataschemaGrid.Columns.Remove("AllowDBNull");
                dataschemaGrid.Columns.Remove("IsReadOnly");
                dataschemaGrid.Columns.Remove("IsUnique");
                dataschemaGrid.Columns.Remove("IsKey");
                dataschemaGrid.Columns.Remove("IsAutoIncrement");
                dataschemaGrid.Columns.Remove("IsRowVersion");
                dataschemaGrid.Columns.Remove("ColumnMapping");
                dataschemaGrid.Columns.Remove("AutoIncrementSeed");
                dataschemaGrid.Columns.Remove("AutoIncrementStep");
                dataschemaGrid.Columns.Remove("BaseCatalogName");
                dataschemaGrid.Columns.Remove("BaseSchemaName");
                dataschemaGrid.Columns.Remove("BaseTableName");
                dataschemaGrid.Columns.Remove("BaseTableNameSpace");
                dataschemaGrid.Columns.Remove("BaseColumnName");
                dataschemaGrid.Columns.Remove("BaseColumnNameSpace");
                dataschemaGrid.Columns.Remove("Expression");
                dataschemaGrid.Columns.Remove("DefaultValue");
                dataschemaGrid.Columns.Remove("ColumnOrdinal");
                dataschemaGrid.Columns.Remove("ColumnSize");
                dataschemaGrid.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                //dataschemaGrid.MasterTemplate.BestFitColumns();
                dataschemaGrid.CellValueChanged += new GridViewCellEventHandler(dataschemaGrid_CellValueChanged);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        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);
            }
        }