public void ColumnEnumerator_InitialState_InvalidUntilMoveNextCalled() { var board = new Board(5, 5); var sut = new ColumnEnumerator(board, 2); Assert.Throws<IndexOutOfRangeException>(() => { var location = sut.Current; }); sut.MoveNext(); Assert.DoesNotThrow(() => { var location = sut.Current; }); }
public void ColumnEnumerator_MoveNext_ReturnsTheExpectedLocation() { var board = new Board(5, 5); board[0, 1].Occupied = Occupied.Red; board[1, 1].Occupied = Occupied.Yellow; board[2, 1].Occupied = Occupied.Red; var sut = new ColumnEnumerator(board, 1); sut.MoveNext(); sut.Current.Occupied.ShouldBe(Occupied.Red); sut.MoveNext(); sut.Current.Occupied.ShouldBe(Occupied.Yellow); sut.MoveNext(); sut.Current.Occupied.ShouldBe(Occupied.Red); }
public void ColumnEnumerator_MoveNext_ReturnsFalseAtEndOfRow() { var board = new Board(5, 5); board[0, 1].Occupied = Occupied.Red; board[1, 1].Occupied = Occupied.Yellow; board[2, 1].Occupied = Occupied.Red; var sut = new ColumnEnumerator(board, 1); sut.MoveNext().ShouldBe(true); sut.MoveNext().ShouldBe(true); sut.MoveNext().ShouldBe(true); sut.MoveNext().ShouldBe(true); sut.MoveNext().ShouldBe(true); sut.MoveNext().ShouldBe(false); }
public static UltraGridColumn GetGridColumn(UltraGrid dg1, string columnKey) { BandEnumerator enumerator = dg1.DisplayLayout.Bands.GetEnumerator(); while (enumerator.MoveNext()) { ColumnEnumerator enumerator2 = enumerator.Current.Columns.GetEnumerator(); while (enumerator2.MoveNext()) { UltraGridColumn current = enumerator2.Current; if (current.Key == columnKey) { return(current); } } } return(null); }
private void Priprema_Load(object sender, EventArgs e) { GODINA_I_MJESEC_OBRACUNADataAdapter adapter = new GODINA_I_MJESEC_OBRACUNADataAdapter(); GODINA_I_MJESEC_OBRACUNADataSet dataSet = new GODINA_I_MJESEC_OBRACUNADataSet(); adapter.Fill(dataSet); this.UltraCombo1.DataSource = dataSet; this.UltraCombo2.DataSource = dataSet; this.UltraCombo1.DataMember = "GODINA_I_MJESEC_OBRACUNA"; this.UltraCombo2.DataMember = "GODINA_I_MJESEC_OBRACUNA"; if (this.UltraCombo1.Rows.Count > 0) { this.UltraCombo1.SelectedRow = this.UltraCombo1.Rows[0]; } if (this.UltraCombo2.Rows.Count > 0) { this.UltraCombo2.SelectedRow = this.UltraCombo2.Rows[0]; } InfraCustom.PostaviSelectAllSvimEditKontrolama(this); this.UltraCombo1.ValueMember = "godinaimjesecobracuna"; this.UltraCombo2.ValueMember = "godinaimjesecobracuna"; ColumnEnumerator enumerator = this.UltraGrid1.DisplayLayout.Bands[0].Columns.GetEnumerator(); while (enumerator.MoveNext()) { UltraGridColumn current = enumerator.Current; if (current.DataType == Type.GetType("System.Decimal")) { if (current.Key != "koeficijent") { current.MaskInput = "{double:9.2}"; } else { current.MaskInput = "{double:4.3}"; } } } }
//AutoGenEntity private void CreateCodeOfEntity(string folder) { var ns = this.cbNameSpaceList.Text.Split(':')[1]; string fileOfCodeCreator = folder + ns + ".entity\\" + this.txtEntityName.Text + "Entity.cs"; CreateDirectory(fileOfCodeCreator); StringBuilder codeBuffer = new StringBuilder(100000); codeBuffer.AppendLine("using System;"); codeBuffer.AppendLine("using stonefw.Utility.EntitySql.Attribute;"); codeBuffer.AppendLine("using stonefw.Utility.EntitySql.Entity;"); codeBuffer.AppendLine(""); codeBuffer.Append("namespace ").Append(ns).AppendLine(".Entity"); codeBuffer.AppendLine("{"); //命名空间 codeBuffer.AppendLine(" [Serializable]"); codeBuffer.Append(" [Table(\"").Append(this.cbDataTableList.Text).AppendLine("\")]"); codeBuffer.Append(" public class ").Append(this.txtEntityName.Text).AppendLine("Entity : BaseEntity"); codeBuffer.AppendLine(" {"); //命名空间 var columns = ColumnEnumerator.GetColumnsOfTable(this.cbDataTableList.Text); for (int i = 0; i < columns.Length; i++) { string objType = GetObjectTypeOfDBColumnForCode(columns[i].ColumnType); if (objType != "string") { objType += "?"; } string dbType = GetDBTypeFromRawType(columns[i].ColumnType); codeBuffer.AppendLine(string.Format(" [Field(\"{0}\")]", columns[i].ColumnName)); codeBuffer.Append(" public ").Append(objType).Append(" ").Append(columns[i].ColumnName); codeBuffer.AppendLine(" { get; set; }"); } codeBuffer.AppendLine(" }"); //Class codeBuffer.AppendLine("}"); //命名空间 File.WriteAllText(fileOfCodeCreator, codeBuffer.ToString()); }
private void CreateCodeOfDetailAspxCs(string fileName) { var n = this.txtEntityName.Text; var ns = this.cbNameSpaceList.Text.Split(':')[1]; var columns = ColumnEnumerator.GetColumnsOfTable(this.cbDataTableList.Text); string identityColumns = ColumnEnumerator.GetIdentityColumn(this.cbDataTableList.Text); string[] primaryKeyColumns = ColumnEnumerator.GetPrimaryKeyColumns(this.cbDataTableList.Text); StringBuilder codeBuffer = new StringBuilder(100000); codeBuffer.AppendLine("using System;"); codeBuffer.AppendLine("using System.Collections.Generic;"); codeBuffer.AppendLine("using System.Linq;"); codeBuffer.AppendLine("using System.Web;"); codeBuffer.AppendLine("using System.Web.UI;"); codeBuffer.AppendLine("using System.Web.UI.WebControls;"); codeBuffer.AppendLine("using stonefw.Biz;"); codeBuffer.AppendLine("using stonefw.Entity;"); codeBuffer.AppendLine("using stonefw.Entity.Enum;"); codeBuffer.AppendLine("using stonefw.Utility;"); codeBuffer.AppendLine("using stonefw.Web.Utility.BaseClass;"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("namespace " + ns + ".web{"); codeBuffer.Append("public partial class ").Append(n).AppendLine("Detail : BasePage"); codeBuffer.AppendLine("{"); codeBuffer.Append("private ").Append(n).AppendLine("Biz _biz;"); codeBuffer.Append("private ") .Append(n) .Append("Biz Biz{get { return _biz ?? (_biz = new ") .Append(n) .AppendLine("Biz()); }"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("protected override bool InitPermission()"); codeBuffer.AppendLine("{"); codeBuffer.AppendLine( "return LoadPermission(SysPermsPointEnum.Add) || LoadPermission(SysPermsPointEnum.Edit);"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("protected void Page_Load(object sender, EventArgs e)"); codeBuffer.AppendLine("{"); codeBuffer.AppendLine("if (!IsPostBack)"); codeBuffer.AppendLine("{"); codeBuffer.AppendLine("FillFormData();"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine("protected void btnSave_Click(object sender, EventArgs e){"); codeBuffer.AppendLine("try{"); codeBuffer.Append("").Append(n).AppendLine("Entity entity = PrepareFormData();"); //新增 string strAddArg = primaryKeyColumns.Aggregate(string.Empty, (current, primaryKey) => current + string.Format("this.{0}.Value == \"-1\"&&", FirstCharLower("hd" + primaryKey))); strAddArg = strAddArg.Substring(0, strAddArg.Length - 2); codeBuffer.Append("if (").Append(strAddArg).AppendLine("){"); codeBuffer.Append("Biz.AddNew").Append(n).AppendLine("(entity);}"); codeBuffer.AppendLine("else"); codeBuffer.Append("{Biz.Update").Append(n).AppendLine("(entity);"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine("base.FatherQuery();"); codeBuffer.AppendLine( "}catch (Exception ex){this.lMessage.Text = string.Format(\"保存失败,原因:{0}\", ex.Message);}"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("private void FillFormData(){"); codeBuffer.AppendLine("try{"); foreach (string column in primaryKeyColumns) { codeBuffer.AppendLine(string.Format("this.{0}.Value = Request[\"{1}\"];", FirstCharLower("hd" + column), column.Replace("_", "").ToLower())); } string strQeruyArg = ""; for (int i = 0; i < primaryKeyColumns.Length; i++) { var type = GetObjectTypeOfDBColumnForCode( columns.Where(m => m.ColumnName == primaryKeyColumns[i]).ToList()[0].ColumnType); if (type == "int") { strQeruyArg += string.Format("{0}.Parse(this.{1}.Value),", type, FirstCharLower("hd" + primaryKeyColumns[i])); } else { strQeruyArg += string.Format("this.{0}.Value,", FirstCharLower("hd" + primaryKeyColumns[i])); } } strQeruyArg = strQeruyArg.Substring(0, strQeruyArg.Length - 1); codeBuffer.AppendLine(string.Format("{0}Entity entity = Biz.Get{0}Entity({1});", n, strQeruyArg)); codeBuffer.AppendLine("if (entity != null){"); for (int i = 0; i < primaryKeyColumns.Length; i++) { strQeruyArg += string.Format("this.{0}.Enabled = false;", FirstCharLower("txt" + primaryKeyColumns[i])); } foreach (SqlServerColumn column in columns) { var type = GetObjectTypeOfDBColumnForCode(column.ColumnType); codeBuffer.AppendLine(type == "bool" ? string.Format("this.{0}.Checked = (bool)entity.{1};", FirstCharLower("cb" + column.ColumnName), column.ColumnName) : string.Format("this.{0}.Text = entity.{1}.ToString();", FirstCharLower("txt" + column.ColumnName), column.ColumnName)); } codeBuffer.AppendLine( "}}catch (Exception ex){this.lMessage.Text = string.Format(\"数据加载失败,原因:{0}\", ex.Message);}"); codeBuffer.AppendLine("}"); codeBuffer.Append("private ").Append(n).AppendLine("Entity PrepareFormData(){"); codeBuffer.AppendLine("//TODO:需要校验参数的合法性"); codeBuffer.Append("var entity = new ").Append(n).AppendLine("Entity();"); foreach (SqlServerColumn column in columns) { var type = GetObjectTypeOfDBColumnForCode(column.ColumnType); switch (type) { case "string": codeBuffer.AppendLine(string.Format("entity.{0} = this.{1}.Text;", column.ColumnName, FirstCharLower("txt" + column.ColumnName))); break; case "bool": codeBuffer.AppendLine(string.Format("entity.{0} = this.{1}.Checked;", column.ColumnName, FirstCharLower("cb" + column.ColumnName))); break; default: codeBuffer.AppendLine(string.Format("entity.{0} = {1}.Parse(this.{2}.Text);", column.ColumnName, type, FirstCharLower("txt" + column.ColumnName))); break; } } codeBuffer.AppendLine("return entity;}}}"); File.WriteAllText(fileName, codeBuffer.ToString()); }
private void CreateCodeOfDetailAspx(string fileName) { var n = this.txtEntityName.Text; var ns = this.cbNameSpaceList.Text.Split(':')[1]; var columns = ColumnEnumerator.GetColumnsOfTable(this.cbDataTableList.Text); string identityColumns = ColumnEnumerator.GetIdentityColumn(this.cbDataTableList.Text); string[] primaryKeyColumns = ColumnEnumerator.GetPrimaryKeyColumns(this.cbDataTableList.Text); //").Append(n).Append(" StringBuilder codeBuffer = new StringBuilder(100000); codeBuffer.Append("<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"") .Append(n) .Append("Detail.aspx.cs\" Inherits=\"") .Append(ns) .Append(".web.") .Append(n) .AppendLine("Detail\" %>"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("<!DOCTYPE html>"); codeBuffer.AppendLine("<html>"); codeBuffer.AppendLine("<head runat=\"server\">"); codeBuffer.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); codeBuffer.AppendLine("<title></title>"); codeBuffer.AppendLine("</head>"); codeBuffer.AppendLine("<body>"); codeBuffer.AppendLine("<form id=\"form1\" runat=\"server\">"); foreach (string column in primaryKeyColumns) { codeBuffer.AppendLine(string.Format("<asp:HiddenField runat=\"server\" ID=\"{0}\" />", FirstCharLower("hd" + column))); } codeBuffer.AppendLine("<div class=\"form\">"); codeBuffer.AppendLine("<table cellpadding=\"5\">"); foreach (var column in columns) { string isReadonly = (column.ColumnName == identityColumns) ? "readonly=\"True\"" : string.Empty; codeBuffer.AppendLine("<tr>"); codeBuffer.AppendLine(string.Format("<td>{0}:</td>", column.ColumnName)); switch (GetObjectTypeOfDBColumnForCode(column.ColumnType)) { case "string": codeBuffer.AppendLine( string.Format( "<td><asp:TextBox ID=\"{0}\" runat=\"server\" MaxLength=\"{1}\" {2} class=\"easyui-textbox\" data-options=\"required:true\"></asp:TextBox></td>", FirstCharLower("txt" + column.ColumnName), column.ColumnSize / 2, isReadonly)); break; case "DateTime": codeBuffer.AppendLine( string.Format( "<td><asp:TextBox ID=\"{0}\" runat=\"server\" class=\"easyui-textbox\" data-options=\"required:true\"></asp:TextBox></td>", FirstCharLower("txt" + column.ColumnName))); break; case "int": case "short": case "long": case "decimal": case "double": case "byte": codeBuffer.AppendLine( string.Format( "<td><asp:TextBox ID=\"{0}\" runat=\"server\" {1} class=\"easyui-textbox\" data-options=\"required:true\"></asp:TextBox></td>", FirstCharLower("txt" + column.ColumnName), isReadonly)); break; case "bool": codeBuffer.AppendLine("<td>"); codeBuffer.AppendLine(string.Format( "<asp:CheckBox runat=\"server\" ID=\"{0}\" Text=\"{1}\" />", FirstCharLower("cb" + column.ColumnName), column.ColumnName)); codeBuffer.AppendLine("</td>"); break; } codeBuffer.AppendLine("</tr>"); } codeBuffer.AppendLine("</table>"); codeBuffer.AppendLine("<div class=\"error\"><asp:Label ID=\"lMessage\" runat=\"server\"></asp:Label></div>"); codeBuffer.AppendLine("<div>"); codeBuffer.AppendLine( "<asp:LinkButton ID=\"btnSave\" runat=\"server\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-ok'\" OnClientClick=\"return saveForm(this);\" OnClick=\"btnSave_Click\">保存</asp:LinkButton>"); codeBuffer.AppendLine( "<a class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-cancel'\" href=\"#\" onclick=\"window.parent.closeDialog();\">取消</a>"); codeBuffer.AppendLine("</div>"); codeBuffer.AppendLine("</div>"); codeBuffer.AppendLine("</form>"); codeBuffer.AppendLine("</body>"); codeBuffer.AppendLine("</html>"); File.WriteAllText(fileName, codeBuffer.ToString()); }
private void CreateCodeOfListAspxCs(string fileName) { var n = this.txtEntityName.Text; var ns = this.cbNameSpaceList.Text.Split(':')[1]; var columns = ColumnEnumerator.GetColumnsOfTable(this.cbDataTableList.Text); string identityColumns = ColumnEnumerator.GetIdentityColumn(this.cbDataTableList.Text); string[] primaryKeyColumns = ColumnEnumerator.GetPrimaryKeyColumns(this.cbDataTableList.Text); StringBuilder codeBuffer = new StringBuilder(100000); codeBuffer.AppendLine("using System;"); codeBuffer.AppendLine("using System.Collections.Generic;"); codeBuffer.AppendLine("using System.Linq;"); codeBuffer.AppendLine("using System.Web;"); codeBuffer.AppendLine("using System.Web.UI;"); codeBuffer.AppendLine("using System.Web.UI.WebControls;"); codeBuffer.AppendLine("using stonefw.Biz;"); codeBuffer.AppendLine("using stonefw.Entity;"); codeBuffer.AppendLine("using stonefw.Entity.Enum;"); codeBuffer.AppendLine("using stonefw.Utility;"); codeBuffer.AppendLine("using stonefw.Web.Utility.BaseClass;"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("namespace " + ns + ".web"); codeBuffer.AppendLine("{"); codeBuffer.Append("public partial class ").Append(n).AppendLine("List : BasePage"); codeBuffer.AppendLine("{"); codeBuffer.Append("private ").Append(n).AppendLine("Biz _biz;"); codeBuffer.Append("private ").Append(n).AppendLine("Biz Biz"); codeBuffer.Append("{ get { return _biz ?? (_biz = new ").Append(n).AppendLine("Biz()); }"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("protected override bool InitPermission(){"); codeBuffer.AppendLine("this.btnAddNew.Visible = LoadPermission(SysPermsPointEnum.Add);"); codeBuffer.Append("this.gv") .Append(n) .AppendLine(".Columns[0].Visible = LoadPermission(SysPermsPointEnum.Delete);"); codeBuffer.Append("this.gv") .Append(n) .AppendLine(".Columns[1].Visible = LoadPermission(SysPermsPointEnum.Edit);"); codeBuffer.AppendLine("return LoadPermission(SysPermsPointEnum.View);"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("protected void Page_Load(object sender, EventArgs e)"); codeBuffer.AppendLine("{if (!IsPostBack)"); codeBuffer.AppendLine("BindData();"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine("protected void btnQuery_Click(object sender, EventArgs e){BindData(); "); codeBuffer.AppendLine("this.lMessage.Text = \"执行成功!\";"); codeBuffer.AppendLine("}"); codeBuffer.Append("protected void gv") .Append(n) .AppendLine("_RowCommand(object sender, GridViewCommandEventArgs e){"); codeBuffer.AppendLine("if (e.CommandName == \"Row_Delete\"){"); codeBuffer.AppendLine("string[] arg = e.CommandArgument.ToString().Split('|');"); //删除 string strDeleteArg = ""; for (int i = 0; i < primaryKeyColumns.Length; i++) { var type = GetObjectTypeOfDBColumnForCode( columns.Where(m => m.ColumnName == primaryKeyColumns[i]).ToList()[0].ColumnType); if (type == "int") { strDeleteArg += string.Format("{0}.Parse(arg[{1}]),", type, i); } else { strDeleteArg += string.Format("arg[{0}],", i); } } strDeleteArg = strDeleteArg.Substring(0, strDeleteArg.Length - 1); codeBuffer.Append("Biz.Delete").Append(n).Append("(").Append(strDeleteArg).AppendLine(");"); codeBuffer.AppendLine("BindData();}}"); codeBuffer.Append("protected void gv") .Append(n) .AppendLine("_PageIndexChanged(object sender, EventArgs e){BindData();"); codeBuffer.AppendLine("}"); codeBuffer.Append("protected void gv") .Append(n) .AppendLine("_PageIndexChanging(object sender, GridViewPageEventArgs e)"); codeBuffer.Append("{this.gv").Append(n).AppendLine(".PageIndex = e.NewPageIndex;"); codeBuffer.AppendLine("}"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("private void BindData()"); codeBuffer.AppendLine("{"); codeBuffer.Append("gv") .Append(n) .AppendLine(".PageSize = int.Parse(base.SysGlobalSetting.GridViewPageSize);"); codeBuffer.Append("gv").Append(n).Append(".DataSource = Biz.Get").Append(n).AppendLine("List();"); codeBuffer.Append("gv").Append(n).AppendLine(".DataBind();"); codeBuffer.AppendLine("}}}"); File.WriteAllText(fileName, codeBuffer.ToString()); }
private void CreateCodeOfListAspx(string fileName) { var n = this.txtEntityName.Text; var ns = this.cbNameSpaceList.Text.Split(':')[1]; var columns = ColumnEnumerator.GetColumnsOfTable(this.cbDataTableList.Text); string identityColumns = ColumnEnumerator.GetIdentityColumn(this.cbDataTableList.Text); string[] primaryKeyColumns = ColumnEnumerator.GetPrimaryKeyColumns(this.cbDataTableList.Text); //").Append(n).Append(" StringBuilder codeBuffer = new StringBuilder(100000); codeBuffer.Append("<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"") .Append(n) .Append("List.aspx.cs\" Inherits=\"") .Append(ns) .Append(".web.") .Append(n) .AppendLine("List\" %>"); codeBuffer.AppendLine(""); codeBuffer.AppendLine("<!DOCTYPE html>"); codeBuffer.AppendLine("<html>"); codeBuffer.AppendLine("<head runat=\"server\">"); codeBuffer.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); codeBuffer.AppendLine("<title></title>"); codeBuffer.AppendLine("</head>"); codeBuffer.AppendLine("<body>"); codeBuffer.AppendLine("<form id=\"form1\" runat=\"server\">"); //form codeBuffer.AppendLine("<div class=\"query\"><table><tr><td>"); codeBuffer.AppendLine( "<asp:LinkButton runat=\"server\" ID=\"btnQuery\" Text=\"查询\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-search'\" OnClick=\"btnQuery_Click\" ></asp:LinkButton>"); //新增 string strAddArg = primaryKeyColumns.Aggregate(string.Empty, (current, primaryKey) => current + primaryKey.Replace("_", "").ToLower() + "=-1&"); strAddArg = strAddArg.Substring(0, strAddArg.Length - 1); codeBuffer.Append( "<asp:LinkButton runat=\"server\" ID=\"btnAddNew\" Text=\"新增\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-add'\" OnClientClick=\"return showDialog('新增', '") .Append(n) .Append("Detail.aspx?") .Append(strAddArg) .AppendLine("',this);\">新增</asp:LinkButton>"); codeBuffer.AppendLine("</td></tr></table></div>"); codeBuffer.Append("<asp:GridView ID=\"gv") .Append(n) .Append( "\" runat=\"server\" AutoGenerateColumns=\"False\" AllowPaging=\"True\" Width=\"100%\" CssClass=\"gridview\""); codeBuffer.Append("OnRowCommand=\"gv") .Append(n) .Append("_RowCommand\" OnPageIndexChanged=\"gv") .Append(n) .Append("_PageIndexChanged\" OnPageIndexChanging=\"gv") .Append(n) .Append("_PageIndexChanging\" >"); codeBuffer.AppendLine("<HeaderStyle HorizontalAlign=\"Center\"></HeaderStyle>"); codeBuffer.AppendLine("<RowStyle HorizontalAlign=\"Center\"></RowStyle>"); codeBuffer.AppendLine("<Columns>"); //删除 codeBuffer.AppendLine("<asp:TemplateField HeaderText=\"删除\" ItemStyle-Width=\"45px\" >"); codeBuffer.AppendLine("<ItemTemplate>"); string strDeleteArg = primaryKeyColumns.Aggregate(string.Empty, (current, primaryKey) => current + string.Format("Eval(\"{0}\")+\"|\"+", primaryKey)); strDeleteArg = strDeleteArg.Substring(0, strDeleteArg.Length - 5); codeBuffer.Append( "<asp:LinkButton class=\"easyui-linkbutton\" runat=\"server\" CommandName=\"Row_Delete\" CommandArgument='<%# ") .Append(strDeleteArg) .AppendLine(" %>' OnClientClick=\"return deleteWarning(this);\">删除</asp:LinkButton>"); codeBuffer.AppendLine("</ItemTemplate>"); codeBuffer.AppendLine("</asp:TemplateField>"); //修改 codeBuffer.AppendLine("<asp:TemplateField HeaderText=\"修改\" ItemStyle-Width=\"45px\" >"); codeBuffer.AppendLine("<ItemTemplate>"); string strEditArg = primaryKeyColumns.Aggregate(string.Empty, (current, primaryKey) => current + string.Format(primaryKey.Replace("_", "").ToLower() + "=\"+Eval(\"{0}\")+\"&", primaryKey)); strEditArg = strEditArg.Substring(0, strEditArg.Length - 1); codeBuffer.Append("<a href=\"#\" class=\"easyui-linkbutton\" onclick='<%# \"showDialog(\\\"修改\\\", \\\"") .Append(n) .Append("Detail.aspx?") .Append(strEditArg) .AppendLine("\\\");\" %>'>修改</a>"); codeBuffer.AppendLine("</ItemTemplate>"); codeBuffer.AppendLine("</asp:TemplateField>"); foreach (SqlServerColumn column in columns) { codeBuffer.AppendLine(string.Format("<asp:BoundField DataField=\"{0}\" HeaderText=\"{0}\" />", column.ColumnName)); } codeBuffer.AppendLine("</Columns>"); codeBuffer.AppendLine("</asp:GridView>"); codeBuffer.AppendLine("<div class=\"error\"><asp:Label ID=\"lMessage\" runat=\"server\"></asp:Label></div>"); codeBuffer.AppendLine("<div id=\"dlg\" class=\"easyui-dialog\" data-options=\"closed:'false'\"></div>"); codeBuffer.AppendLine("</form>"); //form codeBuffer.AppendLine("</body>"); codeBuffer.AppendLine("</html>"); File.WriteAllText(fileName, codeBuffer.ToString()); }
//AutoGenBiz private void CreateCodeOfBiz(string folder) { var n = this.txtEntityName.Text; var ns = this.cbNameSpaceList.Text.Split(':')[1]; var columns = ColumnEnumerator.GetColumnsOfTable(this.cbDataTableList.Text); string identityColumns = ColumnEnumerator.GetIdentityColumn(this.cbDataTableList.Text); string[] primaryKeyColumns = ColumnEnumerator.GetPrimaryKeyColumns(this.cbDataTableList.Text); string fileName = folder + ns + ".biz\\" + this.txtEntityName.Text + "Biz.cs"; CreateDirectory(fileName); var codeBuffer = new StringBuilder(100000); codeBuffer.AppendLine("using System;"); codeBuffer.AppendLine("using System.Collections;"); codeBuffer.AppendLine("using System.Collections.Generic;"); codeBuffer.AppendLine("using System.Data;"); codeBuffer.AppendLine("using System.Data.Common;"); codeBuffer.AppendLine("using System.Linq;"); codeBuffer.AppendLine("using System.Text;"); codeBuffer.AppendLine("using stonefw.Entity;"); codeBuffer.AppendLine("using stonefw.Entity.Enum;"); codeBuffer.AppendLine("using stonefw.Entity.Extension;"); codeBuffer.AppendLine("using stonefw.Entity.SystemModule;"); codeBuffer.AppendLine("using stonefw.Utility;"); codeBuffer.AppendLine("using stonefw.Utility.EntitySql;"); codeBuffer.AppendLine(""); codeBuffer.Append("namespace ").Append(ns).AppendLine(".Biz"); codeBuffer.AppendLine("{"); codeBuffer.Append(" public class ").Append(this.txtEntityName.Text).AppendLine("Biz "); codeBuffer.AppendLine(" {"); //删除 string strDeleteArg1 = ""; string strDeleteArg2 = ""; for (int i = 0; i < primaryKeyColumns.Length; i++) { var type = GetObjectTypeOfDBColumnForCode( columns.Where(m => m.ColumnName == primaryKeyColumns[i]).ToList()[0].ColumnType); strDeleteArg1 += string.Format("{0} {1},", type, FirstCharLower(primaryKeyColumns[i])); strDeleteArg2 += string.Format("{0} = {1},", primaryKeyColumns[i], FirstCharLower(primaryKeyColumns[i])); } strDeleteArg1 = strDeleteArg1.Substring(0, strDeleteArg1.Length - 1); strDeleteArg2 = strDeleteArg2.Substring(0, strDeleteArg2.Length - 1); codeBuffer.Append(" public void Delete").Append(n).Append("(").Append(strDeleteArg1).AppendLine(")"); codeBuffer.AppendLine(" {"); codeBuffer.Append(" ") .Append(n) .Append("Entity entity = new ") .Append(n) .Append("Entity() { ") .Append(strDeleteArg2) .AppendLine(" };"); codeBuffer.AppendLine(" entity.Delete();"); codeBuffer.AppendLine(" }"); //新增 codeBuffer.Append(" public void AddNew").Append(n).Append("(").Append(n).AppendLine("Entity entity)"); codeBuffer.AppendLine(" {"); //如果有自增长的字段,新增时设置为null if (!string.IsNullOrEmpty(identityColumns)) { codeBuffer.Append(" entity.").Append(identityColumns).AppendLine(" = null;"); } codeBuffer.AppendLine(" entity.Insert();"); codeBuffer.AppendLine(" }"); //更新 codeBuffer.Append(" public void Update").Append(n).Append("(").Append(n).AppendLine("Entity entity)"); codeBuffer.AppendLine(" {"); codeBuffer.AppendLine(" entity.Update();"); codeBuffer.AppendLine(" }"); string strQueryArg1 = ""; string strQueryArg2 = ""; for (int i = 0; i < primaryKeyColumns.Length; i++) { var type = GetObjectTypeOfDBColumnForCode( columns.Where(m => m.ColumnName == primaryKeyColumns[i]).ToList()[0].ColumnType); strQueryArg1 += string.Format("{0} {1},", type, FirstCharLower(primaryKeyColumns[i])); strQueryArg2 += string.Format("n.{0} == {1}&&", primaryKeyColumns[i], FirstCharLower(primaryKeyColumns[i])); } strQueryArg1 = strQueryArg1.Substring(0, strQueryArg1.Length - 1); strQueryArg2 = strQueryArg2.Substring(0, strQueryArg2.Length - 2); //查询 codeBuffer.Append(" public ") .Append(n) .Append("Entity Get") .Append(n) .Append("Entity(") .Append(strQueryArg1) .AppendLine(")"); codeBuffer.AppendLine(" {"); codeBuffer.Append(" return EntityExecution.SelectOne<") .Append(n) .Append("Entity>(n => ") .Append(strQueryArg2) .AppendLine(");"); codeBuffer.AppendLine(" }"); //GetList codeBuffer.Append(" public List<").Append(n).Append("Entity> Get").Append(n).AppendLine("List()"); codeBuffer.AppendLine(" {"); codeBuffer.Append(" return EntityExecution.SelectAll<").Append(n).AppendLine("Entity>();"); codeBuffer.AppendLine(" }"); codeBuffer.AppendLine(""); codeBuffer.AppendLine(" #region 扩展方法"); codeBuffer.AppendLine(""); codeBuffer.AppendLine(" private Database _db; "); codeBuffer.AppendLine(" private Database Db "); codeBuffer.AppendLine(" {"); codeBuffer.AppendLine(" get { return _db ?? (_db = DatabaseFactory.CreateDatabase()); }"); codeBuffer.AppendLine(" }"); codeBuffer.AppendLine(""); codeBuffer.AppendLine(" #endregion"); codeBuffer.AppendLine(" }"); //Class codeBuffer.AppendLine("}"); //命名空间 File.WriteAllText(fileName, codeBuffer.ToString()); }
private void IznosiNabave_Load(object sender, EventArgs e) { UltraGridColumn current; this.__CurrencyManager = (CurrencyManager)this.BindingContext[this.dsosnovna.OS]; this.__CurrencyManager.PositionChanged += new EventHandler(this.__CurrencyManager_PositionChanged); this.__CurrencyManager_PositionChanged(null, null); this.daosnovna.Fill(this.dsosnovna); this.m_cm = (CurrencyManager)this.BindingContext[this.ds.S_OS_STANJE_LOKACIJA]; this.m_cm.PositionChanged += new EventHandler(this.m_cm_PositionChanged); InfraCustom.PostaviSelectAllSvimEditKontrolama(this); if (this.dsosnovna.OS.Rows.Count > 0) { this.daStanje.Fill(this.ds, Conversions.ToLong(this.dsosnovna.OS.Rows[0]["invbroj"])); } this.m_bDisablePosCHange = false; this.dalok.Fill(this.dslokacije); this.IzbaciLokacije(); this.UltraGrid1.DataSource = this.ds.S_OS_STANJE_LOKACIJA; this.UltraGrid2.DataSource = this.dslokacije.LOKACIJE; this.UltraGrid3.DataSource = this.dsosnovna.OS; this.m_cmDisable = false; this.m_cm_PositionChanged(null, null); this.UltraGrid1.Text = ""; this.UltraGrid2.Text = ""; this.UltraGrid2.DisplayLayout.Bands[0].Columns[2].Hidden = true; this.UltraGrid2.DisplayLayout.Bands[0].Columns[0].Header.Caption = "Šif.lokacije"; this.UltraGrid2.DisplayLayout.Bands[0].Columns[1].Header.Caption = "Lokacija"; this.UltraGrid1.DisplayLayout.Bands[0].Columns[2].Hidden = true; this.UltraGrid1.DisplayLayout.Bands[0].Columns[3].Hidden = true; this.UltraGrid3.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; this.UltraGrid3.DisplayLayout.Bands[1].Hidden = true; this.UltraGrid3.DisplayLayout.Bands[0].Override.CellClickAction = CellClickAction.RowSelect; ColumnEnumerator enumerator = this.UltraGrid3.DisplayLayout.Bands[0].Columns.GetEnumerator(); while (enumerator.MoveNext()) { current = enumerator.Current; if ((current.Key == "INVBROJ") | (current.Key == "NAZIVOS")) { current.Hidden = false; } else { current.Hidden = true; } } ColumnEnumerator enumerator2 = this.UltraGrid1.DisplayLayout.Bands[0].Columns.GetEnumerator(); while (enumerator2.MoveNext()) { current = enumerator2.Current; if (current.Key == "STANJE") { current.MaskInput = "-nnnnnnnnn.nn"; } } this.UltraGrid3.DisplayLayout.Bands[0].Layout.AutoFitStyle = AutoFitStyle.ExtendLastColumn; this.UltraGrid2.DisplayLayout.Bands[0].Layout.AutoFitStyle = AutoFitStyle.ExtendLastColumn; this.UltraGrid1.DisplayLayout.Bands[0].Layout.AutoFitStyle = AutoFitStyle.ExtendLastColumn; }
public void UcitajHandler(object sender, EventArgs e) { IEnumerator enumerator3 = null; SqlCommand command = new SqlCommand(); SqlConnection connection = new SqlConnection(); command.CommandType = CommandType.StoredProcedure; connection.ConnectionString = Configuration.ConnectionString; command.Connection = connection; command.CommandText = "S_PLACA_GODISNJI"; SqlDataAdapter adapter = new SqlDataAdapter { SelectCommand = command }; adapter.SelectCommand.Parameters.AddWithValue("@od", RuntimeHelpers.GetObjectValue(this.UltraCombo1.Value)); adapter.SelectCommand.Parameters.AddWithValue("@do", RuntimeHelpers.GetObjectValue(this.UltraCombo2.Value)); adapter.SelectCommand.Parameters.AddWithValue("@mjesecni", RuntimeHelpers.GetObjectValue(this.UltraNumericEditor1.Value)); adapter.SelectCommand.Parameters.AddWithValue("@tjedni", 40); DataSet dataSet = new DataSet(); adapter.Fill(dataSet); this.UltraGrid1.DataSource = dataSet; RADNIKDataSet set3 = new RADNIKDataSet(); new RADNIKDataAdapter().Fill(set3); KORISNIKDataSet set2 = new KORISNIKDataSet(); new KORISNIKDataAdapter().Fill(set2); if (Operators.ConditionalCompareObjectEqual(set2.KORISNIK.Rows[0]["STAZUKOEFICIJENTU"], false, false)) { IEnumerator enumerator = null; try { enumerator = set3.RADNIK.GetEnumerator(); while (enumerator.MoveNext()) { int num2 = 0; int num3 = 0; int num4 = 0; IEnumerator enumerator2 = null; DataRow current = (DataRow)enumerator.Current; placa.UkupanRadniStaz(Conversions.ToInteger(current["GODINESTAZA"]), Conversions.ToInteger(current["MJESECISTAZA"]), Conversions.ToInteger(current["DANISTAZA"]), Conversions.ToDate(current["datumzadnjegzaposlenjapromjenefondasati"]), DateAndTime.Today, Conversions.ToInteger(current["tjednifondsatistaz"]), 40, Conversions.ToDecimal(Operators.DivideObject(current["BROJPRIZNATIHMJESECI"], 12)), ref num3, ref num4, ref num2); decimal num = Conversions.ToDecimal(Operators.MultiplyObject(4.65, current["TJEDNIFONDSATI"])); try { enumerator2 = dataSet.Tables[0].Rows.GetEnumerator(); while (enumerator2.MoveNext()) { DataRow row3 = (DataRow)enumerator2.Current; if (Operators.ConditionalCompareObjectEqual(row3["idradnik"], current["idradnik"], false)) { double number = Conversions.ToDouble(Operators.MultiplyObject(current["koeficijent"], 1.0 + ((((double)num3) / 2.0) / 100.0))); row3["koeficijent"] = DB.RoundUpDecimale(number, 3); } } continue; } finally { if (enumerator2 is IDisposable) { (enumerator2 as IDisposable).Dispose(); } } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } } dataSet.Tables[0].Columns.Add("BROJ", Type.GetType("System.Int32")); dataSet.Tables[0].Columns.Add("ukupno", Type.GetType("System.Decimal")); dataSet.Tables[0].Columns.Add("prosjek", Type.GetType("System.Decimal")); dataSet.Tables[0].Columns.Add("prosjecnasatnicagodisnji", Type.GetType("System.Decimal")); dataSet.Tables[0].Columns.Add("placaredovna", Type.GetType("System.Decimal")); dataSet.Tables[0].Columns.Add("prosjecnasatnicaredovna", Type.GetType("System.Decimal")); dataSet.Tables[0].Columns.Add("satigodisnjeg", Type.GetType("System.Decimal")); dataSet.Tables[0].Columns.Add("satiredovnog", Type.GetType("System.Decimal")); dataSet.Tables[0].Columns.Add("brutogodisnjeg", Type.GetType("System.Decimal"), "satigodisnjeg*prosjecnasatnicagodisnji"); dataSet.Tables[0].Columns.Add("brutoredovnog", Type.GetType("System.Decimal"), "satiredovnog*prosjecnasatnicaredovna"); try { enumerator3 = dataSet.Tables[0].Rows.GetEnumerator(); while (enumerator3.MoveNext()) { decimal num8 = 0; DataRow row = (DataRow)enumerator3.Current; int vNumber = 0; int num10 = dataSet.Tables[0].Columns.Count - 1; for (int i = 0; i <= num10; i++) { if (dataSet.Tables[0].Columns[i].ColumnName.ToString().StartsWith("20") & (decimal.Compare(DB.N20(RuntimeHelpers.GetObjectValue(row[i])), decimal.Zero) > 0)) { vNumber++; num8 = decimal.Add(num8, DB.N20(RuntimeHelpers.GetObjectValue(row[i]))); } } row["satigodisnjeg"] = 0; row["satiredovnog"] = 0; row["ukupno"] = num8; try { row["prosjek"] = DB.RoundUpDecimale(decimal.Divide(num8, DB.N20(vNumber)), 2); } catch { row["prosjek"] = 0; } row["BROJ"] = vNumber; try { row["prosjecnasatnicagodisnji"] = DB.RoundUpDecimale(decimal.Divide(decimal.Divide(num8, new decimal(vNumber)), DB.N20(RuntimeHelpers.GetObjectValue(row["sati"]))), 2); } catch (Exception) { row["prosjecnasatnicagodisnji"] = 0; } try { row["prosjecnasatnicaredovna"] = DB.RoundUpDecimale(Operators.DivideObject(Operators.MultiplyObject(row["koeficijent"], 5108.84), DB.N20(RuntimeHelpers.GetObjectValue(row["sati"]))), 2); } catch (Exception) { row["prosjecnasatnicaredovna"] = 0; } row["placaredovna"] = DB.RoundUpDecimale(Operators.MultiplyObject(row["koeficijent"], 5108.84), 2); row["satigodisnjeg"] = RuntimeHelpers.GetObjectValue(row["sati"]); num8 = new decimal(); vNumber = 0; } } finally { if (enumerator3 is IDisposable) { (enumerator3 as IDisposable).Dispose(); } } dataSet.Tables[0].Columns.Add("ukupnopoobracunu", Type.GetType("System.Decimal"), "brutogodisnjeg+ brutoredovnog"); dataSet.Tables[0].Columns.Add("razlika", Type.GetType("System.Decimal"), "ukupnopoobracunu- placaredovna"); ColumnEnumerator enumerator4 = this.UltraGrid1.DisplayLayout.Bands[0].Columns.GetEnumerator(); while (enumerator4.MoveNext()) { UltraGridColumn column2 = enumerator4.Current; if (column2.DataType == Type.GetType("System.Decimal")) { if (column2.Key != "koeficijent") { column2.MaskInput = "{double:9.2}"; } else { column2.MaskInput = "{double:4.3}"; } } } }
private Turn TakeTurn(int column, Occupied occupied) { ValidateRange(column); var columnEnumerator = new ColumnEnumerator(this, column); var availableLocation = columnEnumerator.LastOrDefault(location => location.Occupied == Occupied.None); if (availableLocation == null) // column full return Turn.InvalidTurn; availableLocation.Occupied = occupied; TurnCount++; IsNextTurnRed = !IsNextTurnRed; IsNextTurnYellow = !IsNextTurnYellow; IsWon = IsWinningTurn(availableLocation); return new Turn { Location = availableLocation, IsWinningTurn = IsWon, IsDraw = !IsWon && IsDraw, IsNextTurnRed = IsNextTurnRed, IsNextTurnYellow = IsNextTurnYellow }; }