Ejemplo n.º 1
0
        //
        private string CreateDeleteCommandHandler()
        {
            string dataGridID = "dg" + global.TableProgramatlyName;
            string id         = Globals.GetProgramatlyName(ID.Name);

            id = Globals.ConvetStringToCamelCase(id);
            StringBuilder pageIndexHandler = new StringBuilder();

            pageIndexHandler.Append("\n\tprotected void " + dataGridID + "_DeleteCommand(object source, DataGridCommandEventArgs e)");
            pageIndexHandler.Append("\n\t{");
            //	pageIndexHandler.Append("\n\t\tTestData.Tables[0].Rows.Remove(TestData.Tables[0].Rows.Find(" + global.ViewAllDataGrid + ".DataKeys[e.Item.ItemIndex]));");
            pageIndexHandler.Append("\n\t\t" + Globals.GetAliasDataType(ID.Datatype) + " " + id + " = Convert.To" + Globals.GetDataType(ID.Datatype) + "(" + dataGridID + ".DataKeys[e.Item.ItemIndex]);");
            pageIndexHandler.Append("\n\t\tif(" + global.TableFactoryClass + "." + MethodType.Delete.ToString() + "(" + id + "))");
            pageIndexHandler.Append("\n\t\t{");
            pageIndexHandler.Append("\n\t\tint x = " + dataGridID + ".CurrentPageIndex;");
            pageIndexHandler.Append("\n\t\tif (" + dataGridID + ".PageCount - 1 > x) " + dataGridID + ".CurrentPageIndex = x;");
            pageIndexHandler.Append("\n\t\telse");
            pageIndexHandler.Append("\n\t\t{");
            pageIndexHandler.Append("\n\t\tif (" + dataGridID + ".PageCount != 1)" + dataGridID + ".CurrentPageIndex = x - 1;");
            pageIndexHandler.Append("\n\t\t}");
            pageIndexHandler.Append("\n\t\t\tLoadData();");
            pageIndexHandler.Append("\n\t\t}");
            pageIndexHandler.Append("\n\t}");
            return(pageIndexHandler.ToString());
            //
        }
Ejemplo n.º 2
0
        //
        private string CreateLoadData()
        {
            StringBuilder loadData = new StringBuilder();

            loadData.Append("\n\tprivate void LoadData()");
            loadData.Append("\n\t{");
            loadData.Append("\n\t\tDataTable dtSource= " + global.TableFactoryClass + "." + StoredProcedureTypes.GetAll.ToString() + "();");
            loadData.Append("\n\t\tif(dtSource!=null&&dtSource.Rows.Count >0)");
            loadData.Append("\n\t\t{");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataSource= dtSource;");
            if (ID != null)
            {
                loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataKeyField=\"" + Globals.GetProgramatlyName(ID.Name) + "\";");
            }
            loadData.Append("\n\t\t\tif(" + global.ViewAllDataGrid + ".PageSize>=dtSource.Rows.Count)");
            loadData.Append("\n\t\t\t{");
            loadData.Append("\n\t\t\t\t" + global.ViewAllDataGrid + ".AllowPaging=false;");
            loadData.Append("\n\t\t\t}");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".DataBind();");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".Visible = true;");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".UpdateAfterCallBack = true;");
            loadData.Append("\n\t\t\tlblMsg.Visible = false;");
            loadData.Append("\n\t\t}");
            loadData.Append("\n\t\telse");
            loadData.Append("\n\t\t{");
            loadData.Append("\n\t\t\t" + global.ViewAllDataGrid + ".Visible=false;");
            loadData.Append("\n\t\t\tlblMsg.Visible = true;");
            loadData.Append("\n\t\t}");
            loadData.Append("\n\t}");
            return(loadData.ToString());
        }
        //
        #region ClassMember
        public string CreateEntityPropreties()
        {
            try
            {
                string xmlDocumentation = "";
                //
                StringBuilder EntityPropreties = new StringBuilder();
                //
                string dataType;
                foreach (SQLDMO.Column colCurrent in Fields)
                {
                    dataType = Globals.GetAliasDataType(colCurrent.Datatype);
                    if (dataType == "string")
                    {
                        EntityPropreties.Append("\n\tprivate " + Globals.GetAliasDataType(colCurrent.Datatype) + " _" + Globals.GetProgramatlyName(colCurrent.Name) + "= \"\";");
                    }
                    else if (dataType == "Guid")
                    {
                        EntityPropreties.Append("\n\tprivate " + Globals.GetAliasDataType(colCurrent.Datatype) + " _" + Globals.GetProgramatlyName(colCurrent.Name) + "= Guid.NewGuid();");
                    }
                    else
                    {
                        EntityPropreties.Append("\n\tprivate " + Globals.GetAliasDataType(colCurrent.Datatype) + " _" + Globals.GetProgramatlyName(colCurrent.Name) + ";");
                    }
                    //XML Documentaion
                    xmlDocumentation  = "\n";
                    xmlDocumentation += "\t/// <summary>\n";
                    xmlDocumentation += "\t/// Gets or sets " + SqlProvider.obj.TableName + " " + Globals.GetProgramatlyName(colCurrent.Name) + ". \n";
                    xmlDocumentation += "\t/// </summary>";
                    EntityPropreties.Append(xmlDocumentation);
                    //Propretie body
                    EntityPropreties.Append("\n\tpublic " + Globals.GetAliasDataType(colCurrent.Datatype) + " " + Globals.GetProgramatlyName(colCurrent.Name));
                    EntityPropreties.Append("\n\t{");
                    EntityPropreties.Append("\n\t\tget { return _" + Globals.GetProgramatlyName(colCurrent.Name) + " ; }");
                    EntityPropreties.Append("\n\t\tset { _" + Globals.GetProgramatlyName(colCurrent.Name) + "= value ; }");
                    EntityPropreties.Append("\n\t}");
                    EntityPropreties.Append("\n\t" + Globals.MetthodsSeparator);
                }
                //

                EntityPropreties.Append("\n");
                return(EntityPropreties.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show("My Generated Code Exception:" + ex.Message);
                return("");
            }
        }