public void TwoRows()
		{
			var data = new ArrayList();

			data.Add(new object[] {26, "hammett", "r pereira leite 44"});
			data.Add(new object[] {27, "his girl", "barao bananal 100"});

			var reader = new MockDataReader(data, new[] {"age", "name", "address"}, typeof (int), typeof (String),
			                                typeof (String));

			var binder = new DataBinder();

			var contacts =
				(Contact[])
				binder.BindObject(typeof (Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(2, contacts.Length);

			Assert.AreEqual(26, contacts[0].Age);
			Assert.AreEqual("hammett", contacts[0].Name);
			Assert.AreEqual("r pereira leite 44", contacts[0].Address);

			Assert.AreEqual(27, contacts[1].Age);
			Assert.AreEqual("his girl", contacts[1].Name);
			Assert.AreEqual("barao bananal 100", contacts[1].Address);
		}
		public object Bind(HttpContextBase httpContext, ParameterDescriptor descriptor)
		{
			var binder = new DataBinder();

			var node = new TreeBuilder().BuildSourceNode(httpContext.Request.Params);

			return binder.BindObject(descriptor.Type, Prefix ?? descriptor.Name, Exclude, Allow, node);
		}
		public void CanBindToGenericList()
		{
			int expectedValue = 32;
			var binder = new DataBinder();
			CompositeNode paramsNode = GetParamsNode(expectedValue);
			var myList = (List<int>) binder.BindObject(typeof (List<int>), "myList", paramsNode);

			Assert.AreEqual(expectedValue, myList[0]);
		}
Example #4
0
        public Journey()
        {
            InitializeComponent();
            DataBinder binder = new DataBinder();
            DatabaseController controller = new DatabaseController();

            binder.bindComboBox<Class>(cmbClass, controller.get<Class>("SELECT * FROM class"), "id", "name");
            binder.bindComboBox<Airport>(cmbTo, controller.get<Airport>("SELECT id, CONCAT(name, ' (', id, ')') as name FROM airport"), "id", "name");
            binder.bindComboBox<Airport>(cmbFrom, controller.get<Airport>("SELECT id, CONCAT(name, ' (', id, ')') as name FROM airport"), "id", "name");
            binder.bindComboBox<Airline>(cmbAirline, controller.get<Airline>("SELECT id, name FROM airline"), "id", "name");
        }
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        _user = new User();

        _bindable = new BindableWrapper<User>(_user);
        _bindable.Data.BusinessObj.Username = "******";

        DataBinder binder = new DataBinder(this, _bindable);
        binder.Bind();
    }
		public void CanBindToGenericListInstance()
		{
			int expectedValue = 12;

			var myList = new List<int>();

			var binder = new DataBinder();
			CompositeNode paramsNode = GetParamsNode(expectedValue);

			binder.BindObjectInstance(myList, "myList", paramsNode);
			Assert.AreEqual(expectedValue, myList[0]);
		}
		public void EmptyReader()
		{
			ArrayList data = new ArrayList();

			MockDataReader reader = new MockDataReader(data, new string[] { "name", "address"});
			
			DataBinder binder = new DataBinder();

			Contact[] contacts = (Contact[]) binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(0, contacts.Length);
		}
		public void SingleRow()
		{
			ArrayList data = new ArrayList();

			data.Add( new object[] { "hammett", "r pereira leite 44" } );

			MockDataReader reader = new MockDataReader(data, new string[] { "name", "address"}, typeof(String), typeof(String));
			
			DataBinder binder = new DataBinder();

			Contact[] contacts = (Contact[]) binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(1, contacts.Length);
			Assert.AreEqual("hammett", contacts[0].Name);
			Assert.AreEqual("r pereira leite 44", contacts[0].Address);
		}
		public void UsingTypeConverter()
		{
			ArrayList data = new ArrayList();

			data.Add( new object[] { "hammett", "r pereira leite 44", new DateTime(2006,7,16) } );

			MockDataReader reader = new MockDataReader(data, new string[] { "name", "address", "dob" }, typeof(String), typeof(String), typeof(DateTime));
			
			DataBinder binder = new DataBinder();

			Contact[] contacts = (Contact[]) binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(1, contacts.Length);
			Assert.AreEqual("hammett", contacts[0].Name);
			Assert.AreEqual("r pereira leite 44", contacts[0].Address);
			Assert.IsTrue(contacts[0].DOB.HasValue);
		}
Example #10
0
        public AddFlights()
        {
            InitializeComponent();

            controller = new DatabaseController();
            DataBinder binder = new DataBinder();

            flightCollection = new ObservableCollection<Flight>();
            gridFlights.ItemsSource = flightCollection;

            string queryJourney =
                "SELECT J.id, A1.name as 'from_airport_id', A2.name as 'to_airport_id' FROM journey J LEFT JOIN airport A1 ON J.from_airport_id = A1.id LEFT JOIN airport A2 ON J.to_airport_id = A2.id";
            journey = controller.get<Journey_>(queryJourney);

            journeyList = controller.get<Journey_>("SELECT * FROM journey");
            binder.bindComboBox<Journey_>(cmbJourney, journeyList, "id");
            flightList = controller.get<Flight>("SELECT * FROM flight");
            binder.bindComboBox<Flight>(cmbFlight, flightList, "id");
        }
		public void UsingTranslator()
		{
			ArrayList data = new ArrayList();

			data.Add( new object[] { 26, "hammett", "r pereira leite 44" } );
			data.Add( new object[] { 27, "his girl", "barao bananal 100" } );

			MockDataReader reader = new MockDataReader(data, new string[] { "idade", "nome", "endereco"}, typeof(int), typeof(String), typeof(String));
			
			DataBinder binder = new DataBinder();
			binder.Translator = new EnglishToPortugueseTranslator();

			Contact[] contacts = (Contact[]) binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(2, contacts.Length);
			
			Assert.AreEqual(26, contacts[0].Age);
			Assert.AreEqual("hammett", contacts[0].Name);
			Assert.AreEqual("r pereira leite 44", contacts[0].Address);

			Assert.AreEqual(27, contacts[1].Age);
			Assert.AreEqual("his girl", contacts[1].Name);
			Assert.AreEqual("barao bananal 100", contacts[1].Address);
		}
Example #12
0
    void cellEditor_Init(object sender, EventArgs e)
    {
        ASPxEdit editor = sender as ASPxEdit;
        GridViewDataItemTemplateContainer container = editor.NamingContainer as GridViewDataItemTemplateContainer;

        editor.Width = new Unit(100, UnitType.Percentage);

        ASPxHiddenField hfData = container.Grid.FindTitleTemplateControl("hfData") as ASPxHiddenField;

        string fieldKey = String.Format("{0}_{1}", container.KeyValue, container.Column.FieldName);

        editor.Value = (hfData != null && hfData.Contains(fieldKey)) ? hfData[fieldKey] : DataBinder.Eval(container.DataItem, container.Column.FieldName);

        editor.SetClientSideEventHandler("ValueChanged", String.Format("function(s, e) {{ {0}_hfData.Set('{1}', s.GetValue()); }}", container.Grid.UniqueID, fieldKey));
    }
Example #13
0
        private void grdPromoteSales_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int     activityId = int.Parse(this.grdPromoteSales.DataKeys[e.Row.RowIndex].Value.ToString());
                Label   label      = (Label)e.Row.FindControl("lblmemberGrades");
                Label   label2     = (Label)e.Row.FindControl("lblPromoteType");
                Literal literal    = (Literal)e.Row.FindControl("ltrPromotionInfo");
                IList <MemberGradeInfo> promoteMemberGrades = PromoteHelper.GetPromoteMemberGrades(activityId);
                string str = string.Empty;
                foreach (MemberGradeInfo info in promoteMemberGrades)
                {
                    str = str + info.Name + ",";
                }
                if (!string.IsNullOrEmpty(str))
                {
                    str = str.Remove(str.Length - 1);
                }
                label.Text = str;
                switch (((PromoteType)((int)DataBinder.Eval(e.Row.DataItem, "PromoteType"))))
                {
                case PromoteType.FullAmountDiscount:
                    label2.Text  = "满额打折";
                    literal.Text = string.Format("满足金额:{0} 折扣值:{1}", DataBinder.Eval(e.Row.DataItem, "Condition", "{0:f2}"), DataBinder.Eval(e.Row.DataItem, "DiscountValue", "{0:f2}"));
                    return;

                case PromoteType.FullAmountReduced:
                    label2.Text  = "满额优惠金额";
                    literal.Text = string.Format("满足金额:{0} 优惠金额:{1}", DataBinder.Eval(e.Row.DataItem, "Condition", "{0:f2}"), DataBinder.Eval(e.Row.DataItem, "DiscountValue", "{0:f2}"));
                    return;

                case PromoteType.FullQuantityDiscount:
                    label2.Text  = "满量打折";
                    literal.Text = string.Format("满足数量:{0} 折扣值:{1}", DataBinder.Eval(e.Row.DataItem, "Condition", "{0:f0}"), DataBinder.Eval(e.Row.DataItem, "DiscountValue", "{0:f2}"));
                    return;

                case PromoteType.FullQuantityReduced:
                    label2.Text  = "满量优惠金额";
                    literal.Text = string.Format("满足数量:{0},优惠金额:{1}", DataBinder.Eval(e.Row.DataItem, "Condition", "{0:f0}"), DataBinder.Eval(e.Row.DataItem, "DiscountValue", "{0:f2}"));
                    return;

                case PromoteType.FullAmountSentGift:
                    label2.Text  = "满额送礼品";
                    literal.Text = string.Format("满足金额:{0} <a  href=\"javascript:DialogFrame('promotion/gifts.aspx?isPromotion=true','查看促销礼品',null,null)\">查看促销礼品</a>", DataBinder.Eval(e.Row.DataItem, "Condition", "{0:f2}"));
                    return;

                case PromoteType.FullAmountSentTimesPoint:
                    label2.Text  = "满额送倍数积分";
                    literal.Text = string.Format("满足金额:{0},倍数:{1}", DataBinder.Eval(e.Row.DataItem, "Condition", "{0:f2}"), DataBinder.Eval(e.Row.DataItem, "DiscountValue", "{0:f2}"));
                    return;

                case PromoteType.FullAmountSentFreight:
                    label2.Text  = "满额免运费";
                    literal.Text = string.Format("满足金额:{0}", DataBinder.Eval(e.Row.DataItem, "Condition", "{0:f2}"));
                    return;

                default:
                    return;
                }
            }
        }
 protected void GridInword_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     try
     {
         if (e.Row.RowType == DataControlRowType.DataRow && !string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "InwardNo"))))
         {
             //Taxamt += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "DiscAmnt"));
             SubTotal     += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "SubTotal"));
             Discount     += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Discount"));
             Vat          += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Vat"));
             DekhrekhAmt  += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "DekhrekhAmt"));
             HamaliAmt    += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "HamaliAmt"));
             CESSAmt      += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "CESSAmt"));
             FreightAmt   += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "FreightAmt"));
             PackingAmt   += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "PackingAmt"));
             PostageAmt   += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "PostageAmt"));
             OtherCharges += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "OtherCharges"));
             GrandTotal   += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "GrandTotal"));
         }
         if (e.Row.RowType == DataControlRowType.Footer)
         {
             e.Row.Cells[6].Text  = "Total";
             e.Row.Cells[7].Text  = SubTotal.ToString("0.00");
             e.Row.Cells[8].Text  = Discount.ToString("0.00");
             e.Row.Cells[9].Text  = Vat.ToString("0.00");
             e.Row.Cells[10].Text = DekhrekhAmt.ToString("0.00");
             e.Row.Cells[11].Text = HamaliAmt.ToString("0.00");
             e.Row.Cells[12].Text = CESSAmt.ToString("0.00");
             e.Row.Cells[13].Text = FreightAmt.ToString("0.00");
             e.Row.Cells[14].Text = PackingAmt.ToString("0.00");
             e.Row.Cells[15].Text = PostageAmt.ToString("0.00");
             e.Row.Cells[16].Text = OtherCharges.ToString("0.00");
             e.Row.Cells[17].Text = GrandTotal.ToString("0.00");
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public void Should_bind_multiple_attr()
        {
            var actual = new DataBinder<TestModel>().Attr("src", m => m.Description).Attr("alt", m => m.TotalItems).ToHtmlString();

            Assert.AreEqual(@"data-bind=""attr: { src: Description, alt: TotalItems }""", actual);
        }
Example #16
0
        protected void gvImportBL_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                GeneralFunctions.ApplyGridViewAlternateItemStyle(e.Row, 6);
                ScriptManager sManager = ScriptManager.GetCurrent(this);

                e.Row.Cells[0].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobNo"));
                e.Row.Cells[1].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobDate")).Split(' ')[0];
                e.Row.Cells[2].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobType"));
                e.Row.Cells[3].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocName"));
                e.Row.Cells[4].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "POL"));
                e.Row.Cells[5].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "POD"));
                e.Row.Cells[6].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "EstPayable"));
                e.Row.Cells[7].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "EstReceivable"));
                e.Row.Cells[8].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "EstProfit"));

                ImageButton btnDashboard = (ImageButton)e.Row.FindControl("btnDashboard");
                btnDashboard.ToolTip         = "Dashboard";
                btnDashboard.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobId"));

                // display HBL button only Open Job
                if (ddlJobStatus.SelectedValue == "O")
                {
                    ImageButton btnHBLEntry = (ImageButton)e.Row.FindControl("btnHBLEntry");
                    btnHBLEntry.ToolTip = "HBL Entry";
                    if (Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "PrintHBL")))
                    {
                        btnHBLEntry.Visible         = true;
                        btnHBLEntry.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobId"));
                    }
                    else
                    {
                        btnHBLEntry.Visible = false;
                    }
                }
                else
                {
                    ImageButton btnHBLEntry = (ImageButton)e.Row.FindControl("btnHBLEntry");
                    btnHBLEntry.Visible = false;
                }
                //Edit Link
                ImageButton btnEdit = (ImageButton)e.Row.FindControl("btnEdit");
                btnEdit.ToolTip         = ResourceManager.GetStringWithoutName("ERR00070");
                btnEdit.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobId"));

                //Delete link
                if (_canDelete == true)
                {
                    ImageButton btnRemove = (ImageButton)e.Row.FindControl("btnRemove");
                    btnRemove.Visible         = true;
                    btnRemove.ToolTip         = ResourceManager.GetStringWithoutName("ERR00007");
                    btnRemove.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobId"));
                    btnRemove.Attributes.Add("onclick", "javascript:return confirm('Are you sure about delete?');");
                }
                else
                {
                    ImageButton btnRemove = (ImageButton)e.Row.FindControl("btnRemove");
                    btnRemove.Visible = false;
                }

                if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobActive")) == "C")
                {
                    e.Row.ForeColor = System.Drawing.Color.Red;
                    ImageButton btnRemove = (ImageButton)e.Row.FindControl("btnRemove");
                    btnRemove.Visible = false;
                }
            }
        }
Example #17
0
 protected void spgvSettings_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowIndex == -1)
     {
         return;
     }
     ((TextBox)e.Row.Cells[0].FindControl("txtExtension")).Text  = DataBinder.Eval(e.Row.DataItem, "Extension").ToString();
     ((TextBox)e.Row.Cells[1].FindControl("txtSize")).Text       = DataBinder.Eval(e.Row.DataItem, "Size").ToString();
     ((CheckBox)e.Row.Cells[2].FindControl("chbActive")).Checked = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "Active").ToString());
 }
Example #18
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton lb = (LinkButton)e.Row.FindControl("DeleteButton1");
                lb.Attributes.Add("onclick", "return confirm('คุณต้องการจะลบชื่องาน / ฝ่าย " + DataBinder.Eval(e.Row.DataItem, "WORK_NAME") + " ใช่ไหม ?');");

                if ((e.Row.RowState & DataControlRowState.Edit) > 0)
                {
                    TextBox txt1 = (TextBox)e.Row.FindControl("txtWorkDivisionIDEdit");
                    txt1.Attributes.Add("onkeypress", "return allowOnlyNumber(this);");
                    TextBox txt2 = (TextBox)e.Row.FindControl("txtCampusIDEdit");
                    txt2.Attributes.Add("onkeypress", "return allowOnlyNumber(this);");
                    TextBox txt3 = (TextBox)e.Row.FindControl("txtFacultyIDEdit");
                    txt3.Attributes.Add("onkeypress", "return allowOnlyNumber(this);");
                    TextBox txt4 = (TextBox)e.Row.FindControl("txtDivisionIDEdit");
                    txt4.Attributes.Add("onkeypress", "return allowOnlyNumber(this);");
                }
            }
        }
Example #19
0
        public static void ExportToCSV <T>(
            string filename
            , IEnumerable <T> source
            , Dictionary <string, string> columnDefinition
            , string cookieName = "DescargaCompleta"
            , string valueName  = "1")
        {
            List <string> columns      = new List <string>();
            CsvWriter     writer       = null;
            var           memoryStream = new MemoryStream();

            using (StreamWriter streamWriter = new StreamWriter(memoryStream, System.Text.Encoding.UTF8))
            {
                writer = new CsvWriter(streamWriter);
                //writer.WriteRecords(source);


                foreach (KeyValuePair <string, string> keyvalue in columnDefinition)
                {
                    writer.WriteField(keyvalue.Value);
                    columns.Add(keyvalue.Key);
                }
                writer.NextRecord();

                foreach (var dataItem in (IEnumerable)source)
                {
                    foreach (string column in columns)
                    {
                        foreach (PropertyInfo property in dataItem.GetType().GetProperties())
                        {
                            if (column == property.Name)
                            {
                                if (property.PropertyType == typeof(bool?) || property.PropertyType == typeof(bool))
                                {
                                    string value = DataBinder.GetPropertyValue(dataItem, property.Name, null);
                                    writer.WriteField(string.IsNullOrEmpty(value) ? "" : (value == "True" ? "Si" : "No"));
                                }
                                else if (property.PropertyType == typeof(decimal?) || property.PropertyType == typeof(decimal))
                                {
                                    string value = DataBinder.GetPropertyValue(dataItem, property.Name, null);
                                    writer.WriteField(string.Format("{0:N2}", value));
                                }
                                else if (property.PropertyType == typeof(int?) || property.PropertyType == typeof(int))
                                {
                                    string value = DataBinder.GetPropertyValue(dataItem, property.Name, null);
                                    writer.WriteField <int>(Convert.ToInt32(value));
                                }
                                else
                                {
                                    writer.WriteField(DataBinder.GetPropertyValue(dataItem, property.Name, null));
                                }
                                break;
                            }
                        }
                    }
                    writer.NextRecord();
                }
            }


            var originalFileName = Path.GetFileNameWithoutExtension(filename) + ".csv";

            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.Clear();
            //HttpContext.Current.Response.SetCookie("Cache-Control", "private");
            if (!string.IsNullOrEmpty(cookieName) && !string.IsNullOrEmpty(valueName))
            {
                HttpContext.Current.Response.AppendCookie(new HttpCookie(cookieName, valueName));
            }
            HttpContext.Current.Response.Buffer = false;
            HttpContext.Current.Response.AddHeader("Content-disposition", "attachment; filename=" + originalFileName);
            HttpContext.Current.Response.Charset = "UTF-8";
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Private);
            //HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();

            memoryStream.Dispose();
        }
Example #20
0
        public static void ExportToExcel <T>(
            string filename
            , IEnumerable <T> source
            , Dictionary <string, string> columnDefinition
            , string sheetName  = "Reporte"
            , string cookieName = "DescargaCompleta"
            , string valueName  = "1")
        {
            var originalFileName = Path.GetFileNameWithoutExtension(filename) + ".xlsx";

            var           wb      = new XLWorkbook();
            var           ws      = wb.Worksheets.Add(sheetName);
            List <string> columns = new List <string>();
            int           index   = 1;

            foreach (KeyValuePair <string, string> keyvalue in columnDefinition)
            {
                //Establece las columnas
                ws.Cell(1, index).Value = keyvalue.Value;
                index++;
                columns.Add(keyvalue.Key);
            }

            int row = 2;

            foreach (var dataItem in (IEnumerable)source)
            {
                var col = 1;
                foreach (string column in columns)
                {
                    foreach (PropertyInfo property in dataItem.GetType().GetProperties())
                    {
                        if (column == property.Name)
                        {
                            if (property.PropertyType == typeof(bool?) || property.PropertyType == typeof(bool))
                            {
                                string value = DataBinder.GetPropertyValue(dataItem, property.Name, null);
                                ws.Cell(row, col).Value = (string.IsNullOrEmpty(value) ? "" : (value == "True" ? "Si" : "No"));
                            }
                            else if (property.PropertyType == typeof(decimal?) || property.PropertyType == typeof(decimal))
                            {
                                string value = DataBinder.GetPropertyValue(dataItem, property.Name, null);
                                ws.Cell(row, col).Value = string.Format("{0:N2}", value);
                            }
                            else if (property.PropertyType == typeof(int?) || property.PropertyType == typeof(int))
                            {
                                string value = DataBinder.GetPropertyValue(dataItem, property.Name, null);
                                ws.Cell(row, col).Value    = value;
                                ws.Cell(row, col).DataType = XLCellValues.Number;
                            }
                            else
                            {
                                if (property.PropertyType == typeof(DateTime?) || property.PropertyType == typeof(DateTime))
                                {
                                    ws.Cell(row, col).Style.DateFormat.Format = "dd/MM/yyyy";
                                }
                                else
                                {
                                    ws.Cell(row, col).Style.NumberFormat.Format = "@";
                                }
                                ws.Cell(row, col).Value = DataBinder.GetPropertyValue(dataItem, property.Name, null);
                            }
                            break;
                        }
                    }
                    col++;
                }
                row++;
            }
            ws.Range(1, 1, 1, index - 1).AddToNamed("Titles");

            var titlesStyle = wb.Style;

            titlesStyle.Font.Bold                = true;
            titlesStyle.Font.FontColor           = XLColor.White;
            titlesStyle.Alignment.Horizontal     = XLAlignmentHorizontalValues.Center;
            titlesStyle.Fill.BackgroundColor     = XLColor.FromHtml("#006600");
            titlesStyle.Border.BottomBorder      = XLBorderStyleValues.Thin;
            titlesStyle.Border.BottomBorderColor = XLColor.Black;
            titlesStyle.Border.TopBorder         = XLBorderStyleValues.Thin;
            titlesStyle.Border.TopBorderColor    = XLColor.Black;
            titlesStyle.Border.RightBorder       = XLBorderStyleValues.Thin;
            titlesStyle.Border.RightBorderColor  = XLColor.Black;
            titlesStyle.Border.LeftBorder        = XLBorderStyleValues.Thin;
            titlesStyle.Border.LeftBorderColor   = XLColor.Black;

            wb.NamedRanges.NamedRange("Titles").Ranges.Style = titlesStyle;
            ws.Columns().AdjustToContents();

            var stream = new MemoryStream();

            wb.SaveAs(stream);

            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.Clear();
            //HttpContext.Current.Response.SetCookie("Cache-Control", "private");
            if (!string.IsNullOrEmpty(cookieName) && !string.IsNullOrEmpty(valueName))
            {
                HttpContext.Current.Response.AppendCookie(new HttpCookie(cookieName, valueName));
            }
            HttpContext.Current.Response.Buffer = false;
            HttpContext.Current.Response.AddHeader("Content-disposition", "attachment; filename=" + originalFileName);
            HttpContext.Current.Response.Charset = "UTF-8";
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Private);
            //HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.BinaryWrite(stream.ToArray());
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();

            stream.Dispose();
        }
Example #21
0
        /// <summary>
        /// 初始化窗体///
        /// </summary>
        protected override void InitializeForm()
        {
            // //_BLL = new bllWMS_Bill();// 业务逻辑层实例
            _BLL                = new bllWMS_Task();
            _SummaryView        = new DevGridView(gvSummary);
            _ActiveEditor       = textTaskId;
            _DetailGroupControl = panelControl1;

            base.InitializeForm(); //这行代码放到初始化变量后最好

            frmGridCustomize.RegisterGrid(gvSummary);
            frmGridCustomize.AddMenuItem(gvSummary, "入库任务新建", null, OnTaskAllInNewClick, true);
            frmGridCustomize.AddMenuItem(gvSummary, "任务下发", null, OnTaskAssignClick2, true);
            frmGridCustomize.AddMenuItem(gvSummary, "入库口入库", null, OnTaskArrivalPort_InClick, true);
            frmGridCustomize.AddMenuItem(gvSummary, "到达入库站台", null, OnTaskArrivalStation_InClick, true);
            frmGridCustomize.AddMenuItem(gvSummary, "堆垛机接收任务", null, OnTaskScReceiveClick, true);
            frmGridCustomize.AddMenuItem(gvSummary, "堆垛机完成任务", null, OnTaskScFinishClick, true);
            frmGridCustomize.AddMenuItem(gvSummary, "达到出库站台", null, OnTaskArrivalStation_OutClick, true);
            frmGridCustomize.AddMenuItem(gvSummary, "达到出库口", null, OnTaskArrivalPort_OutClick, true);
            frmGridCustomize.AddMenuItem(gvSummary, "任务过账", null, OnTaskFinishTaskClick, true);
            #region
            //if (SystemAuthentication.ButtonAuthorized("MenuItemTaskAssign"))
            //{
            //    frmGridCustomize.AddMenuItem(gvSummary, "任务下发", null, OnTaskAssignClick, true);
            //}
            //if (SystemAuthentication.ButtonAuthorized("MenuItemTaskCancel"))
            //{
            //    frmGridCustomize.AddMenuItem(gvSummary, "任务取消", null, OnTaskCancelClick, true);
            //}
            //if (SystemAuthentication.ButtonAuthorized("MenuItemTaskManualAccount"))
            //{
            //    frmGridCustomize.AddMenuItem(gvSummary, "手动过账", null, OnTaskAccountByManualClick, true);
            //}
            //if (SystemAuthentication.ButtonAuthorized("MenuItemTaskStatusModify"))
            //{
            //    frmGridCustomize.AddMenuItem(gvSummary, "状态修改", null, OnTaskStatusModifyClick, true);
            //}
            //if (SystemAuthentication.ButtonAuthorized("MenuItemTaskStationModify"))
            //{
            //    frmGridCustomize.AddMenuItem(gvSummary, "站台修改", null, OnTaskStationModifyClick, true);
            //}
            //if (SystemAuthentication.ButtonAuthorized("MenuItemTaskPortModify"))
            //{
            //    frmGridCustomize.AddMenuItem(gvSummary, "出库口修改", null, OnTaskPortNumModifyClick, true);
            //}
            //if (SystemAuthentication.ButtonAuthorized("MenuItemTaskPriorityModify"))
            //{
            //    frmGridCustomize.AddMenuItem(gvSummary, "优先级修改", null, OnTaskPriorityModifyClick, true);
            //}
            #endregion


            DevStyle.SetGridControlLayout(gcSummary, false); //表格设置
            DevStyle.SetGridControlLayout(gcDetail, true);   //表格设置
            DevStyle.SetSummaryGridViewLayout(gvSummary);
            DevStyle.SetDetailGridViewLayout(gvDetail);
            //主表
            BindingSummaryNavigator(controlNavigatorSummary, gcSummary); //Summary导航条.
            BindingSummarySearchPanel(btnQuery, btnEmpty, gcFindGroup);

            gvSummary.DoubleClick   += new EventHandler(OnSeeTask); //主表DoubleClict
            txt_DocDateFrom.DateTime = DateTime.Today.AddDays(-7);
            txt_DocDateTo.DateTime   = DateTime.Today.AddDays(1);   //查询条件


            DataBinder.BindingLookupEditDataSource(lookUpEditDocType, DataDictCache.Cache.TaskType, tb_CommonDataDict.NativeName, tb_CommonDataDict.DataCode);
            DataBinder.BindingLookupEditDataSource(lookUpEditDocStatus, DataDictCache.Cache.TaskStatus, tb_CommonDataDict.NativeName, tb_CommonDataDict.DataCode);
            DataBinder.BindingLookupEditDataSource(repositoryItemLookUpEditDocType, DataDictCache.Cache.TaskType, tb_CommonDataDict.NativeName, tb_CommonDataDict.DataCode);
            DataBinder.BindingLookupEditDataSource(repositoryItemLookUpEditDocStatus, DataDictCache.Cache.TaskStatus, tb_CommonDataDict.NativeName, tb_CommonDataDict.DataCode);

            _BLL.GetBusinessByKey("-", true); //加载一个空的业务对象.
            DoSearchSummary();
            ShowSummaryPage(true);            //一切初始化完毕后显示SummaryPage
        }
Example #22
0
        protected void resourceGrid_ItemCreated(object sender, DataGridItemEventArgs e)
        {
            string text = "<img src=\"{0}\" border=\"0\"/>";

            if (e.Item.DataItem != null)
            {
                text = String.Format(text, damHandlerURL + "/" + DataBinder.Eval(e.Item.DataItem, "LibraryName").ToString() + "/" + DataBinder.Eval(e.Item.DataItem, "ResourceName").ToString() + ".dam?thumbnail=1&size=40&DAM_culture=" + CurrentCultureCode);
            }
            e.Item.Cells[1].Text = text;
        }
Example #23
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            GridView
                tmpGridView;

            if ((tmpGridView = sender as GridView) == null)
            {
                return;
            }

            string
                tmpString = "GridView_RowDataBound(sender.GetType().FullName=\"" + sender.GetType().FullName + "\" e.GetType().FullName=\"" + e.GetType().FullName + "\")";

            if (tmpString != string.Empty)
            {
                LogII.LogII.MakeFile(LogII.LogII.MakeLogFileName(), tmpString, true);
            }

            DataRowView
                tmpDataRowView;

            if ((tmpDataRowView = e.Row.DataItem as System.Data.DataRowView) != null)
            {
                LogII.LogII.MakeFile(LogII.LogII.MakeLogFileName(), "System.Data.DataRowView", true);
            }

            DbDataRecord
                tmpDbDataRecord;

            if ((tmpDbDataRecord = e.Row.DataItem as DbDataRecord) != null)
            {
                LogII.LogII.MakeFile(LogII.LogII.MakeLogFileName(), "DbDataRecord", true);
            }

            string
                FieldName = "Salary";

            switch (tmpGridView.ID)
            {
            case "GridView1":
            {
                switch (e.Row.RowType)
                {
                case DataControlRowType.Header:
                {
                    Total = 0m;

                    break;
                }

                case DataControlRowType.DataRow:
                {
                    decimal
                        tmpDecimal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, FieldName));

                    Total += tmpDecimal;

                    break;
                }
                }

                break;
            }

            case "GridView2":
            {
                switch (e.Row.RowType)
                {
                case DataControlRowType.Header:
                {
                    Total = 0m;

                    break;
                }

                case DataControlRowType.DataRow:
                {
                    decimal
                        tmpDecimal = !((DataRowView)e.Row.DataItem).Row.IsNull(FieldName) ? Convert.ToDecimal(((DataRowView)e.Row.DataItem).Row[FieldName]) : 0m;

                    //decimal
                    //	tmpDecimal = !(e.Row.DataItem as System.Data.DataRowView).Row.IsNull(FieldName) ? Convert.ToDecimal((e.Row.DataItem as System.Data.DataRowView).Row[FieldName]) : 0m;

                    Total += tmpDecimal;

                    break;
                }

                case DataControlRowType.Footer:
                {
                    e.Row.Cells[0].Text            = "<b>»того:</b>";
                    e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left;
                    e.Row.Cells[1].Text            = "<b>" + Total.ToString("c") + "</b>";
                    e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Right;

                    break;
                }
                }

                break;
            }
            }
        }
Example #24
0
 protected void repCategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
     {
         //DropDownList ddlSeqNo = (DropDownList)e.Item.FindControl("ddlSeqNo");
         //Image imgCategory = (Image)e.Item.FindControl("imgCategory");
         HyperLink hlEdit = (HyperLink)e.Item.FindControl("hlEdit");
         hlEdit.NavigateUrl = Page.ResolveUrl("~/addeditExpenseDetails.aspx?id=" + ocommon.Encrypt(DataBinder.Eval(e.Item.DataItem, "id").ToString(), true));
         //imgCategory.ImageUrl = categoryFrontPath + DataBinder.Eval(e.Item.DataItem, "imagename").ToString();
         //Fill_SeqNo(Convert.ToInt64(DataBinder.Eval(e.Item.DataItem, "SeqNo")), Convert.ToInt64(DataBinder.Eval(e.Item.DataItem, "MaxSeqNo")), ref ddlSeqNo);
     }
 }
Example #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow) //判断是否是DataRow,以防止鼠标经过Header也有效果
                {
                    e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='#BCE2F9';");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e");

                    HiddenField hid = (HiddenField)e.Row.FindControl("Hid_ID");
                    //业务申请的ID
                    string ID = DataBinder.Eval(e.Row.DataItem, "ID").ToString();
                    hid.Value = ID;

                    //项目状态
                    string status = DataBinder.Eval(e.Row.DataItem, "Status").ToString();
                    switch (status)
                    {
                    case "0":
                        e.Row.Cells[9].Text = "待确认";
                        break;

                    case "1":
                        e.Row.Cells[9].Text = "已确认";
                        break;

                    case "2":
                        e.Row.Cells[9].Text = "<font color='red'>已撤销</font>";
                        break;

                    case "3":
                        e.Row.Cells[9].Text = "<font color='red'>挂起</font>";
                        break;
                    }

                    //申请人用户名
                    string SendUserUserName = DataBinder.Eval(e.Row.DataItem, "SendUserName").ToString();
                    //申请人真实姓名
                    string SendUserRealName = DataBinder.Eval(e.Row.DataItem, "SendRealName").ToString();
                    //申请人
                    e.Row.Cells[8].Text = SendUserRealName + "[" + SendUserUserName + "]";

                    //使用开始时间
                    DateTime StartTime = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "StartTime").ToString());
                    //使用结束时间
                    DateTime EndTime = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "EndTime").ToString());
                    e.Row.Cells[1].Text = StartTime.GetDateTimeFormats('f')[0].ToString() + " 至</br>" + EndTime.GetDateTimeFormats('f')[0].ToString();
                    if (StartTime.Date == EndTime.Date)
                    {
                        e.Row.Cells[1].Text = StartTime.ToLongDateString() + "</br>" + StartTime.ToShortTimeString() + " 至 " + EndTime.ToShortTimeString();
                    }
                    //用途
                    string Overviews = DataBinder.Eval(e.Row.DataItem, "Overviews").ToString();
                    Overviews           = string.IsNullOrEmpty(Overviews) == true ? "无" : Overviews;
                    e.Row.Cells[3].Text = "<a href='#' title='用途:" + Overviews + "'> " + e.Row.Cells[3].Text + "</a>";
                }
            }
            catch
            {
            }
        }
        public void Should_bind_hasFocus()
        {
            var actual = new DataBinder<TestModel>().HasFocus(m => m.IsActive).ToHtmlString();

            Assert.AreEqual(@"data-bind=""hasFocus: IsActive""", actual);
        }
Example #27
0
    protected void dlBlogComments_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        //LinkButton delete_button = (LinkButton)dlBlogComments.FindControl("lnkbtnDelete");
        try
        {
            if (Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "poster_id")) == Convert.ToInt32(Session["user_id"]) && Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "is_admin")) == 0)
            {
                System.Web.UI.HtmlControls.HtmlGenericControl divoptions = (System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("div_blog_comment_options");

                LinkButton DeleteButton = new LinkButton();
                DeleteButton.ID              = "lnkbtnDelete";
                DeleteButton.Command        += new CommandEventHandler(lnkbtnDelete_Command);
                DeleteButton.CommandArgument = DataBinder.Eval(e.Item.DataItem, "comment_id").ToString();
                DeleteButton.CssClass        = "lnkbtnDelete";
                DeleteButton.Text            = "Delete";

                divoptions.Controls.Add(DeleteButton);

                ScriptManager1.RegisterAsyncPostBackControl(DeleteButton);


                //add the profile pic of the commenter
            }

            Image imgpp = (Image)e.Item.FindControl("img_commenter_pic");
            imgpp.ImageUrl = GetImageUrl(Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "poster_id")), Convert.ToInt16(DataBinder.Eval(e.Item.DataItem, "is_admin")));
        }

        catch (Exception ex)
        {
            ErrorReportBAL error = new ErrorReportBAL();
            error.SendErrorReport("ViewPost.aspx", ex.ToString());
            Response.Write("<script>alert('Some Error Occured \n Sorry for inconvenience');</script>");
        }
    }
Example #28
0
    protected void rptAdv_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        LinkButton btnLink = (LinkButton)e.Item.FindControl("btnLink");

        btnLink.ToolTip = DataBinder.Eval(e.Item.DataItem, "MenuLinksName").ToString();
        //  btnLink.Attributes.Add("onclick", "javascript:window.open('" + DataBinder.Eval(e.Item.DataItem, "MenuLinksUrl") + "','_blank','width=1024,height=600');return false;");


        //btnLink.Attributes.Add("onclick", "javascript:window.open('" + ResolveUrl("~/") + "Client/Admin/News/ViewNewsGroup.aspx?Id=" + DataBinder.Eval(e.Item.DataItem, "NewsGroupID") + "','_blank','width=800,height=600');return false;");


        string  Imgthumb      = DataBinder.Eval(e.Item.DataItem, "MenuLinksIcon").ToString();
        Literal ltlImageThumb = (Literal)e.Item.FindControl("ltlICON");

        if (Imgthumb != "")
        {
            ltlImageThumb.Text = @"<img src='" + Imgthumb + "' width='" + DataBinder.Eval(e.Item.DataItem, "Width").ToString() + "' height='" + DataBinder.Eval(e.Item.DataItem, "Height").ToString() + "' alt='" + DataBinder.Eval(e.Item.DataItem, "MenuLinksName").ToString() + "' >";
        }
    }
Example #29
0
        protected void gdv_Usuarios_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton Lb = (LinkButton)e.Row.FindControl("Deshabilitarbtn");
                Lb.Attributes.Add("OnClick", "return confirm('Esta seguro de que desea Deshabilitar el Usuario de nombre " + DataBinder.Eval(e.Row.DataItem, "nombreUsuario") + "?')");
                LinkButton Lb2 = (LinkButton)e.Row.FindControl("Habilitarbtn");
                Lb2.Attributes.Add("OnClick", "return confirm('Esta seguro de que desea Habilitar el Usuario de nombre " + DataBinder.Eval(e.Row.DataItem, "nombreUsuario") + "?')");

                if (DataBinder.Eval(e.Row.DataItem, "bloqueado").ToString() == "True")
                {
                    Lb.Visible  = false;
                    Lb2.Visible = true;
                }
                if (DataBinder.Eval(e.Row.DataItem, "bloqueado").ToString() == "False")
                {
                    Lb.Visible  = true;
                    Lb2.Visible = false;
                }
            }
        }
Example #30
0
        protected void rpProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            bool isShoes = bool.Parse(DataBinder.Eval(e.Item.DataItem, "DepartamentIsTypeShoes").ToString());

            this.LoadSizeGeneric(isShoes, e);
        }
		public void Init()
		{
			builder = new TreeBuilder();
			binder = new DataBinder();
		}
Example #32
0
// <snippet5>
        private void RecurseDataBindInternal(TreeNode node,
                                             IHierarchicalEnumerable enumerable, int depth)
        {
            foreach (object item in enumerable)
            {
                IHierarchyData data = enumerable.GetHierarchyData(item);

                if (null != data)
                {
                    // Create an object that represents the bound data
                    // to the control.
                    TreeNode     newNode = new TreeNode();
                    RootViewNode rvnode  = new RootViewNode();

                    rvnode.Node  = newNode;
                    rvnode.Depth = depth;

                    // The dataItem is not just a string, but potentially
                    // an XML node or some other container.
                    // If DataTextField is set, use it to determine which
                    // field to render. Otherwise, use the first field.
                    if (DataTextField.Length > 0)
                    {
                        newNode.Text = DataBinder.GetPropertyValue
                                           (data, DataTextField, null);
                    }
                    else
                    {
                        PropertyDescriptorCollection props =
                            TypeDescriptor.GetProperties(data);

                        // Set the "default" value of the node.
                        newNode.Text = String.Empty;

                        // Set the true data-bound value of the TextBox,
                        // if possible.
                        if (props.Count >= 1)
                        {
                            if (null != props[0].GetValue(data))
                            {
                                newNode.Text =
                                    props[0].GetValue(data).ToString();
                            }
                        }
                    }

                    Nodes.Add(rvnode);

                    if (data.HasChildren)
                    {
                        IHierarchicalEnumerable newEnumerable =
                            data.GetChildren();
                        if (newEnumerable != null)
                        {
                            RecurseDataBindInternal(newNode,
                                                    newEnumerable, depth + 1);
                        }
                    }

                    if (_maxDepth < depth)
                    {
                        _maxDepth = depth;
                    }
                }
            }
        }
        public void Should_bind_multiple_style()
        {
            var actual = new DataBinder<TestModel>().Style("fontWeight", m => m.Description).Style("textDecoration", m => m.TotalItems).ToHtmlString();

            Assert.AreEqual(@"data-bind=""style: { fontWeight: Description, textDecoration: TotalItems }""", actual);
        }
Example #34
0
        private static DateTime GetAddDateByContext(PageInfo pageInfo, ContextInfo contextInfo)
        {
            var addDate = DateUtils.SqlMinValue;

            if (contextInfo.ContextType == EContextType.Content)
            {
                if (contextInfo.ContentInfo == null)
                {
                    var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, contextInfo.ChannelId);
                    //addDate = DataProvider.ContentDao.GetAddDate(tableName, contextInfo.ContentId);
                    addDate = Content.GetAddDate(tableName, contextInfo.ContentId);
                }
                else
                {
                    addDate = contextInfo.ContentInfo.AddDate;
                }
            }
            else if (contextInfo.ContextType == EContextType.Channel)
            {
                var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId);

                addDate = channel.AddDate;
            }
            else
            {
                if (contextInfo.ItemContainer != null)
                {
                    //else if (contextInfo.ItemContainer.InputItem != null)
                    //{
                    //    addDate = (DateTime)DataBinder.Eval(contextInfo.ItemContainer.InputItem.DataItem, InputContentAttribute.AddDate);
                    //}
                    //else if (contextInfo.ItemContainer.ContentItem != null)
                    //{
                    //    addDate = (DateTime)DataBinder.Eval(contextInfo.ItemContainer.ContentItem.DataItem, ContentAttribute.AddDate);
                    //}
                    //else if (contextInfo.ItemContainer.ChannelItem != null)
                    //{
                    //    addDate = (DateTime)DataBinder.Eval(contextInfo.ItemContainer.ChannelItem.DataItem, NodeAttribute.AddDate);
                    //}
                    if (contextInfo.ItemContainer.SqlItem != null)
                    {
                        addDate = (DateTime)DataBinder.Eval(contextInfo.ItemContainer.SqlItem.DataItem, "AddDate");
                    }
                }
                else if (contextInfo.ContentId != 0)//获取内容
                {
                    if (contextInfo.ContentInfo == null)
                    {
                        var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, contextInfo.ChannelId);
                        //addDate = DataProvider.ContentDao.GetAddDate(tableName, contextInfo.ContentId);
                        addDate = Content.GetAddDate(tableName, contextInfo.ContentId);
                    }
                    else
                    {
                        addDate = contextInfo.ContentInfo.AddDate;
                    }
                }
                else if (contextInfo.ChannelId != 0)//获取栏目
                {
                    var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId);
                    addDate = channel.AddDate;
                }
            }

            return(addDate);
        }
        public void Should_bind_style()
        {
            var actual = new DataBinder<TestModel>().Style("fontWeight", m => m.Description).ToHtmlString();

            Assert.AreEqual(@"data-bind=""style: { fontWeight: Description }""", actual);
        }
            public TestForm(Person person)
            {
                this.person = person;
                name.Name = "name";
                _name.Name = "_name";
                inputbox.Name = "inputbox";
                Control holder = flowPanel;
                Label lNewLabel = new Label() { Text = "name" };
                holder.Controls.Add(lNewLabel);
                holder.Controls.Add(name);
                holder.Controls.Add(new Label(){Text = "_name"});
                holder.Controls.Add(_name);
                holder.Controls.Add(new Label() { Text = "input"});
                holder.Controls.Add(inputbox);
                flowPanel.Dock = DockStyle.Fill;
                Controls.Add(flowPanel);
                BindableWrapper<Person> _bindable = new BindableWrapper<Person>(person);
                DataBinder<Person, Form> dataBinder  = new DataBinder<Person, Form>( _bindable, this);
                dataBinder.BindWithReflection();

                inputbox.TextChanged += (sender, ea) => person.Name = inputbox.Text;

                //inputbox.TextChanged += (sender, ea) => name.Text = inputbox.Text;
            }
        public void Should_bind_checked()
        {
            var actual = new DataBinder<TestModel>().Checked(m => m.IsActive).ToHtmlString();

            Assert.AreEqual(@"data-bind=""checked: IsActive""", actual);
        }
		public ActionExecutionSink()
		{
			DataBinder = new DataBinder();
		}
        public void Should_bind_checkedValue()
        {
            var actual = new DataBinder<TestModel>().CheckedValue(m => m.Items).ToHtmlString();

            Assert.AreEqual(@"data-bind=""checkedValue: Items""", actual);
        }
Example #40
0
        protected void GridView1_OnRowCreated(Object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string s  = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "CustID"));
                bool?  mu = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "musteri"));
                if (mu == true)
                {
                    (e.Row.FindControl("btnServisler") as LinkButton).PostBackUrl = "~/TeknikTeknik/ServislerCanli.aspx?custid=" + s;
                }
                else
                {
                    bool?tam = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "disservis"));
                    if (tam == true)
                    {
                        (e.Row.FindControl("btnServisler") as LinkButton).PostBackUrl = "~/TeknikTeknik/ServisTamirci.aspx?tamirid=" + s;
                    }
                    else
                    {
                        if (User.IsInRole("Admin") || User.IsInRole("mudur"))
                        {
                            bool?ust = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "usta"));
                            if (ust == true)
                            {
                                (e.Row.FindControl("btnServisler") as LinkButton).PostBackUrl = "~/TeknikTeknik/ServisMaliyetler.aspx?tamirci=" + s;
                            }
                        }
                    }
                }
                //(e.Row.FindControl("btnServisler") as LinkButton).PostBackUrl = "~/TeknikTeknik/ServislerCanli.aspx?custid=" + DataBinder.Eval(e.Row.DataItem, "CustID");

                (e.Row.FindControl("btnMusteriDetay") as LinkButton).PostBackUrl = "~/MusteriDetayBilgileri.aspx?custid=" + DataBinder.Eval(e.Row.DataItem, "CustID");
                //(e.Row.FindControl("btnMusteriDetayK") as LinkButton).PostBackUrl = "~/MusteriDetayBilgileri.aspx?custid=" + DataBinder.Eval(e.Row.DataItem, "CustID");
            }
        }
Example #41
0
        internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo)
        {
            var parsedContent = string.Empty;

            if (contextInfo.ItemContainer?.SqlItem == null)
            {
                return(string.Empty);
            }

            try
            {
                var attributeName = stlEntity.Substring(5, stlEntity.Length - 6);
                parsedContent = StringUtils.StartsWithIgnoreCase(attributeName, StlParserUtility.ItemIndex) ? StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.SqlItem.ItemIndex, attributeName, contextInfo).ToString() : DataBinder.Eval(contextInfo.ItemContainer.SqlItem.DataItem, attributeName, "{0}");
            }
            catch
            {
                // ignored
            }

            return(parsedContent);
        }
Example #42
0
        /// <devdoc>
        /// </devdoc>
        private void OnDataBindField(object sender, EventArgs e)
        {
            Debug.Assert((DataTextField.Length != 0) || (DataNavigateUrlFields.Length != 0),
                         "Shouldn't be DataBinding without a DataTextField and DataNavigateUrlField");

            HyperLink boundControl     = (HyperLink)sender;
            Control   controlContainer = boundControl.NamingContainer;
            object    dataItem         = null;


            if (controlContainer == null)
            {
                throw new HttpException(SR.GetString(SR.DataControlField_NoContainer));
            }

            // Get the DataItem from the container
            dataItem = DataBinder.GetDataItem(controlContainer);

            if (dataItem == null && !DesignMode)
            {
                throw new HttpException(SR.GetString(SR.DataItem_Not_Found));
            }

            if ((textFieldDesc == null) && (urlFieldDescs == null))
            {
                PropertyDescriptorCollection props = TypeDescriptor.GetProperties(dataItem);
                string fieldName;

                fieldName = DataTextField;
                if (fieldName.Length != 0)
                {
                    textFieldDesc = props.Find(fieldName, true);
                    if ((textFieldDesc == null) && !DesignMode)
                    {
                        throw new HttpException(SR.GetString(SR.Field_Not_Found, fieldName));
                    }
                }

                string[] dataNavigateUrlFields       = DataNavigateUrlFields;
                int      dataNavigateUrlFieldsLength = dataNavigateUrlFields.Length;
                urlFieldDescs = new PropertyDescriptor[dataNavigateUrlFieldsLength];

                for (int i = 0; i < dataNavigateUrlFieldsLength; i++)
                {
                    fieldName = dataNavigateUrlFields[i];
                    if (fieldName.Length != 0)
                    {
                        urlFieldDescs[i] = props.Find(fieldName, true);
                        if ((urlFieldDescs[i] == null) && !DesignMode)
                        {
                            throw new HttpException(SR.GetString(SR.Field_Not_Found, fieldName));
                        }
                    }
                }
            }

            string dataTextValue = String.Empty;

            if (textFieldDesc != null && dataItem != null)
            {
                object data = textFieldDesc.GetValue(dataItem);
                dataTextValue = FormatDataTextValue(data);
            }
            if (DesignMode && (DataTextField.Length != 0) && dataTextValue.Length == 0)
            {
                dataTextValue = SR.GetString(SR.Sample_Databound_Text);
            }

            if (dataTextValue.Length > 0)
            {
                boundControl.Text = dataTextValue;
            }

            int    urlFieldDescsLength = urlFieldDescs.Length;
            string dataNavValue        = String.Empty;

            if (urlFieldDescs != null && urlFieldDescsLength > 0 && dataItem != null)
            {
                object[] data = new object[urlFieldDescsLength];

                for (int i = 0; i < urlFieldDescsLength; i++)
                {
                    if (urlFieldDescs[i] != null)
                    {
                        data[i] = urlFieldDescs[i].GetValue(dataItem);
                    }
                }
                string urlValue = FormatDataNavigateUrlValue(data);
                if (!CrossSiteScriptingValidation.IsDangerousUrl(urlValue))
                {
                    dataNavValue = urlValue;
                }
            }
            if (DesignMode && (DataNavigateUrlFields.Length != 0) && dataNavValue.Length == 0)
            {
                dataNavValue = "url";
            }

            if (dataNavValue.Length > 0)
            {
                boundControl.NavigateUrl = dataNavValue;
            }
        }
Example #43
0
        /// <summary>
        /// Handles the Bind event of the Files control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataListItemEventArgs"/> instance containing the event data.</param>
        public void Files_Bind([NotNull] object sender, [NotNull] DataListItemEventArgs e)
        {
            var directoryPath = Path.Combine(YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Avatars);

            var fname = (Literal)e.Item.FindControl("fname");

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var finfo = new FileInfo(
                    this.Server.MapPath(Convert.ToString(DataBinder.Eval(e.Item.DataItem, "name"))));

                if (this.CurrentDirectory.IsSet())
                {
                    directoryPath = this.CurrentDirectory;
                }

                string tmpExt = finfo.Extension.ToLower();

                if (tmpExt == ".gif" || tmpExt == ".jpg" || tmpExt == ".jpeg" || tmpExt == ".png" || tmpExt == ".bmp")
                {
                    string link;
                    var    encodedFileName = finfo.Name.Replace(".", "%2E");

                    if (this.returnUserID > 0)
                    {
                        link = YafBuildLink.GetLink(
                            ForumPages.admin_edituser,
                            "u={0}&av={1}",
                            this.returnUserID,
                            this.Server.UrlEncode("{0}/{1}".FormatWith(directoryPath, encodedFileName)));
                    }
                    else
                    {
                        link = YafBuildLink.GetLink(
                            ForumPages.cp_editavatar,
                            "av={0}",
                            this.Server.UrlEncode("{0}/{1}".FormatWith(directoryPath, encodedFileName)));
                    }

                    fname.Text =
                        @"<div style=""text-align:center""><a href=""{0}""><img src=""{1}"" alt=""{2}"" title=""{2}"" class=""borderless"" /></a><br /><small>{2}</small></div>{3}"
                        .FormatWith(
                            link,
                            "{0}/{1}".FormatWith(directoryPath, finfo.Name),
                            finfo.Name,
                            Environment.NewLine);
                }
            }

            if (e.Item.ItemType != ListItemType.Header)
            {
                return;
            }

            // get the previous directory...
            string previousDirectory = Path.Combine(YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Avatars);

            var up = e.Item.FindControl("up") as LinkButton;

            up.CommandArgument = previousDirectory;
            up.Text            =
                @"<p style=""text-align:center""><img src=""{0}images/folder.gif"" alt=""Up"" /><br />UP</p>".FormatWith
                    (YafForumInfo.ForumClientFileRoot);
            up.ToolTip = this.GetText("UP_TITLE");

            // Hide if Top Folder
            if (this.CurrentDirectory.Equals(previousDirectory))
            {
                up.Visible = false;
            }
        }
        public void Should_bind_attr()
        {
            var actual = new DataBinder<TestModel>().Attr("src", m => m.Description).ToHtmlString();

            Assert.AreEqual(@"data-bind=""attr: { src: Description }""", actual);
        }
Example #45
0
 public void RecipeCat_ItemDataBound(Object s, RepeaterItemEventArgs e)
 {
     Utility.GetIdentifyItemNewPopular(Convert.ToDateTime(DataBinder.Eval(e.Item.DataItem, "Date")), e,
                                       (int)DataBinder.Eval(e.Item.DataItem, "Hits"));
 }
        public void Should_bind_simple_bindings_once()
        {
            var actual = new DataBinder<TestModel>().Text(m => m.Description).Text(m => m.Description).ToHtmlString();

            Assert.AreEqual(@"data-bind=""text: Description""", actual);
        }
Example #47
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            DataRowView drv = e.Row.DataItem as DataRowView;

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton lb = (LinkButton)e.Row.FindControl("DeleteButton1");
                lb.Attributes.Add("onclick", "return confirm('คุณต้องการจะลบรหัสสถานภาพ " + DataBinder.Eval(e.Row.DataItem, "STATUS_ID") + " ใช่ไหม ?');");

                if ((e.Row.RowState & DataControlRowState.Edit) > 0)
                {
                    TextBox txt = (TextBox)e.Row.FindControl("txtStatusPersonIDEDIT");
                    txt.Attributes.Add("onkeypress", "return allowOnlyNumber(this);");
                }
            }
        }
        public void Should_bind_uniqueName()
        {
            var actual = new DataBinder<TestModel>().UniqueName().ToHtmlString();

            Assert.AreEqual(@"data-bind=""uniqueName: true""", actual);
        }
Example #49
0
        private void SetDate()
        {
            Int32 intyearid = Convert.ToInt32(ddlDateRange.SelectedValue);

            objFinYearDAL = new FinYearDAL();
            var lst = objFinYearDAL.FilldateFromTo(intyearid);

            objFinYearDAL    = null;
            hidmindate.Value = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[0], "StartDate"))) ? "" : Convert.ToString(Convert.ToDateTime(DataBinder.Eval(lst[0], "StartDate")).ToString("dd-MM-yyyy"));
            hidmaxdate.Value = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lst[0], "EndDate"))) ? "" : Convert.ToString(Convert.ToDateTime(DataBinder.Eval(lst[0], "EndDate")).ToString("dd-MM-yyyy"));
            if (ddlDateRange.SelectedIndex >= 0)
            {
                if (Convert.ToDateTime(ApplicationFunction.mmddyyyy(hidmaxdate.Value)) >= DateTime.Now.Date && DateTime.Now.Date >= Convert.ToDateTime(ApplicationFunction.mmddyyyy(hidmindate.Value)))
                {
                    txtDateFrom.Text = hidmindate.Value;
                    txtDateTo.Text   = DateTime.Now.Date.ToString("dd-MM-yyyy");
                }
                else
                {
                    txtDateFrom.Text = hidmindate.Value;
                    txtDateTo.Text   = DateTime.Now.Date.ToString("dd-MM-yyyy");
                }
            }
        }
        public void Should_replace_previous_binding()
        {
            var actual = new DataBinder<TestModel>().Text(m => m.Description).Text(m => m.TotalItems).ToHtmlString();

            Assert.AreEqual(@"data-bind=""text: TotalItems""", actual);
        }
        protected void Rep_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            string sql = "";

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                StringBuilder sb   = new StringBuilder();
                Control       ctrl = e.Item.Controls[0];
                Literal       lit  = (Literal)ctrl.FindControl("LitColnums");
                if (lit != null)
                {
                    // sql = "select Code,MC from a_eke_sysModelItems where ModelID='" + modelid + "' and delTag=0 and Custom=0 order by PX";
                    //lit.Text = eOleDB.getOptions(sql, "MC", "Code", DataBinder.Eval(e.Item.DataItem, "Code").ToString());
                    DataTable     dt  = getColumns(dr["code"].ToString());
                    StringBuilder _sb = new StringBuilder();
                    foreach (DataRow _dr in dt.Rows)
                    {
                        _sb.Append("<option value=\"" + _dr["code"].ToString() + "\"" + (_dr["code"].ToString().ToLower() == DataBinder.Eval(e.Item.DataItem, "Code").ToString().ToLower() ? " selected" : "") + ">" + _dr["mc"].ToString() + "</option>");
                    }
                    lit.Text = _sb.ToString();
                }

                lit = (Literal)ctrl.FindControl("LitObjects");
                #region 绑定对象
                if (lit != null)
                {
                    for (int i = 0; i < AllTables.Rows.Count; i++)
                    {
                        sb.Append("<option value=\"" + AllTables.Rows[i]["name"].ToString() + "\"" + (DataBinder.Eval(e.Item.DataItem, "BindObject").ToString() == AllTables.Rows[i]["name"].ToString() ? " selected" : "") + " title=\"" + AllTables.Rows[i]["name"].ToString() + "\">" + AllTables.Rows[i]["name"].ToString() + "</option>\r\n");
                    }
                    lit.Text = sb.ToString();
                    if (DataBinder.Eval(e.Item.DataItem, "BindObject").ToString().Length > 0)
                    {
                        lit = (Literal)ctrl.FindControl("LitValue");
                        if (lit != null)
                        {
                            sql      = "select b.name from sysobjects a inner join  syscolumns b on a.id=b.id where a.name='" + DataBinder.Eval(e.Item.DataItem, "BindObject").ToString() + "' order by b.colid";//b.colid";
                            lit.Text = eOleDB.getOptions(sql, "name", "name", DataBinder.Eval(e.Item.DataItem, "BindValue").ToString());

                            lit = (Literal)ctrl.FindControl("LitText");
                            if (lit != null)
                            {
                                lit.Text = eOleDB.getOptions(sql, "name", "name", DataBinder.Eval(e.Item.DataItem, "BindText").ToString());
                            }
                        }
                    }
                }
                #endregion
                #region  项
                lit = (Literal)ctrl.FindControl("LitOptions");
                if (lit != null)
                {
                    //HtmlControl hc = (HtmlControl)ctrl.FindControl("spanbind");
                    HtmlGenericControl hc = (HtmlGenericControl)ctrl.FindControl("spanbind");
                    if (hc != null)
                    {
                        //hc.Attributes.Add("style","border:1px solid #ff0000");
                        //Response.Write("has<br>");
                    }
                    sb  = new StringBuilder();
                    sql = "select ModelConditionItemID,mc,conditionvalue,px from a_eke_sysModelConditionItems where ModelConditionID='" + DataBinder.Eval(e.Item.DataItem, "ModelConditionID").ToString() + "' and delTag=0 order by px,addTime ";
                    DataTable tb = eOleDB.getDataTable(sql);
                    // sb.Append("<a href=\"?act=addconditem&modelid=" + modelid + "&cid=" + DataBinder.Eval(e.Item.DataItem, "ModelConditionID").ToString() + "\">添加选项</a><br>");


                    sb.Append("<table id=\"eDataTable\" class=\"eDataTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" widt5h=\"100%\">");
                    sb.Append("<thead>");
                    sb.Append("<tr>");
                    sb.Append("<td height=\"25\" width=\"30\" bgc3olor=\"#ffffff\" align=\"center\"><a title=\"添加选项\" href=\"javascript:;\" onclick=\"addModelConditionItem(this,'" + DataBinder.Eval(e.Item.DataItem, "ModelConditionID").ToString() + "');\"><img width=\"16\" height=\"16\" src=\"images/add.jpg\" border=\"0\"></a></td>");
                    sb.Append("<td width=\"110\">&nbsp;选项名称</td>");
                    sb.Append("<td width=\"150\">&nbsp;条件</td>");
                    sb.Append("<td width=\"60\">&nbsp;显示顺序</td>");
                    sb.Append("</tr>");
                    sb.Append("</thead>");
                    if (tb.Rows.Count > 0)
                    {
                        if (hc != null)
                        {
                            hc.Attributes.Add("style", "display:none;");
                        }
                        for (int i = 0; i < tb.Rows.Count; i++)
                        {
                            sb.Append("<tr" + ((i + 1) % 2 == 0 ? " class=\"alternating\" eclass=\"alternating\"" : " eclass=\"\"") + " onmouseover=\"this.className='cur';\" onmouseout=\"this.className=this.getAttribute('eclass');\">");
                            sb.Append("<td height=\"32\" align=\"center\"><a title=\"删除选项\" href=\"javascript:;\" onclick=\"delModelConditionItem(this,'" + tb.Rows[i]["ModelConditionItemID"].ToString() + "');\"><img width=\"16\" height=\"16\" src=\"images/del.jpg\" border=\"0\"></a></td>");
                            sb.Append("<td><input type=\"text\" value=\"" + tb.Rows[i]["mc"].ToString() + "\" oldvalue=\"" + tb.Rows[i]["mc"].ToString() + "\" class=\"edit\"  onBlur=\"setModelConditionItem(this,'" + tb.Rows[i]["ModelConditionItemID"].ToString() + "','mc');\" /></td>");
                            sb.Append("<td><input type=\"text\" value=\"" + tb.Rows[i]["conditionvalue"].ToString() + "\" oldvalue=\"" + tb.Rows[i]["conditionvalue"].ToString() + "\" class=\"edit\"  onBlur=\"setModelConditionItem(this,'" + tb.Rows[i]["ModelConditionItemID"].ToString() + "','conditionvalue');\" /></td>");
                            sb.Append("<td><input reload=\"true\" type=\"text\" value=\"" + (tb.Rows[i]["px"].ToString() == "999999" || tb.Rows[i]["px"].ToString() == "0" ? "" : tb.Rows[i]["px"].ToString()) + "\" oldvalue=\"" + (tb.Rows[i]["px"].ToString() == "999999" || tb.Rows[i]["px"].ToString() == "0" ? "" : tb.Rows[i]["px"].ToString()) + "\" class=\"edit\"  onBlur=\"setModelConditionItem(this,'" + tb.Rows[i]["ModelConditionItemID"].ToString() + "','px');\" /></td>");
                            sb.Append("</tr>");
                        }
                    }
                    sb.Append("</table>");

                    lit.Text = sb.ToString();
                }
                #endregion
            }
        }
        public void Should_bind_enable()
        {
            var actual = new DataBinder<TestModel>().Enable(m => m.IsActive).ToHtmlString();

            Assert.AreEqual(@"data-bind=""enable: IsActive""", actual);
        }
Example #53
0
        protected void GrdParentGrid_RowDataBound(object sender, RepeaterItemEventArgs e)
        {
            var drv = e.Item.DataItem as DataRowView;

            if (drv == null)
            {
                return;
            }

            var hdnField    = e.Item.FindControl("hdnScheduleDetailId") as HiddenField;
            var btnInsert   = e.Item.FindControl("btnInsert") as LinkButton;
            var btnCheckBox = e.Item.FindControl("chkbox") as LinkButton;

            //tab control or detail Grid Container DIV
            var detailsGridContainer = e.Item.FindControl("detailsGridContainer") as HtmlGenericControl;

            if (oSearchFilter.GroupBy == "Person")
            {
                //var btnInsert = e.Item.FindControl("btnInsert") as LinkButton;
                btnInsert.PostBackUrl  = Page.GetRouteUrl("ScheduleDetailEntityRoute", new { Action = "Insert" });
                btnInsert.PostBackUrl += "/" + hdnField.Value;
            }

            var parentKey     = string.Empty;
            var parentKeyName = parentKey = DataBinder.Eval(e.Item.DataItem, "Person").ToString();

            //ReleaseLog = (DataBinder.Eval(e.Item.DataItem, "Name")).ToString();
            //ReleaseLog = parentKey;

            if (oSearchFilter.GroupBy == "-1" || string.IsNullOrEmpty(oSearchFilter.GroupBy) || oSearchFilter.GroupBy == "All")
            {
                parentKey         = hdnField.Value;
                btnInsert.Visible = false;
                //btnCheckBox.Visible = false;
            }
            else
            {
                parentKey = DataBinder.Eval(e.Item.DataItem, "Key").ToString();
            }

            //data set for the current group
            var filteredGroup = GetDataDetailsByKey(parentKey);

            var statisticItem = ScheduleDetailDataManager.GetStatisticData(filteredGroup, ScheduleDataModel.DataColumns.ScheduleTimeSpentConstant, ApplicationCommon.ScheduleStatisticUnknown);

            AddSummaryStatisticLine(parentKey, statisticItem);

            if (!String.IsNullOrEmpty(oSearchFilter.GroupBy.Trim()) &&
                oSearchFilter.GroupBy != "-1" &&
                oSearchFilter.GroupBy != "All" &&
                !String.IsNullOrEmpty(oSearchFilter.SubGroupBy) &&
                oSearchFilter.SubGroupBy != "-1" &&
                oSearchFilter.SubGroupBy != "All")
            //&&	filteredGroup.Columns.Contains(oSearchFilter.SubGroupBy)
            {
                // get new instance of tab control to added for the group
                var tabControl = ApplicationCommon.GetNewDetailTabControl();
                tabControl.Setup(SettingCategory);

                var subGroupByColumn = oSearchFilter.SubGroupBy;

                // Add Group By Key Information
                var grpByDiv = new HtmlGenericControl("div");
                grpByDiv.InnerHtml = "<strong>Group: " + parentKey + " </strong>";
                TableReportContent.Controls.Add(grpByDiv);

                // Add Header Row for Statistics table
                TableReportContent.Controls.Add(GetStatisticInfoHTMLHeaderRow(subGroupByColumn));

                // get distinct sub group by values
                var distinctFieldValues = (from row in filteredGroup.AsEnumerable()
                                           .Where(row => row[subGroupByColumn].ToString().Trim() != "")
                                           orderby row[subGroupByColumn].ToString().Trim() descending
                                           select row[subGroupByColumn].ToString().Trim())
                                          .Distinct(StringComparer.CurrentCultureIgnoreCase);

                var series = new decimal[filteredGroup.Rows.Count];
                var i      = 0;

                foreach (DataRow item in filteredGroup.Rows)
                {
                    var timeSpent = item[ScheduleDetailDataModel.DataColumns.DateDiffHrs].ToString();

                    var timeSpentValue = 0m;

                    Decimal.TryParse(timeSpent, out timeSpentValue);

                    series[i++] = timeSpentValue;
                }

                var totalHoursWorkedForGroup = series.Sum();


                var mainDiv = new HtmlGenericControl("table");
                mainDiv.Attributes["class"] = "table table-bordered";

                // create tab for each sub group by distinct value
                foreach (var key in distinctFieldValues)
                {
                    var detailContainer = new HtmlGenericControl("div");
                    //detailContainer.Style.Add("Width", "100%");

                    // Add DetailsWithChildrenControl
                    var ctlDetailsWithChildren = Page.LoadControl(ApplicationCommon.DetailsWithChildrenListControl) as DetailsWithChildrenControl;

                    ctlDetailsWithChildren.FieldConfigurationMode = ddlFieldConfigurationMode.SelectedValue;
                    ctlDetailsWithChildren.SettingCategory        = SettingCategory + "DetailsWithChildrenControl";
                    ctlDetailsWithChildren.IsFCModeVisible        = false;
                    ctlDetailsWithChildren.Setup("ScheduleDetail", "ScheduleDetail", "ScheduleDetailId", parentKey, subGroupByColumn, key, true, GetSubGroupData, GetColumns, "ScheduleDetail", DetailUserPreferenceCategoryId);
                    ctlDetailsWithChildren.SetVisibilityOfListFeatures(false, false, false);
                    ctlDetailsWithChildren.SetSession("true");
                    //ctlDetailsWithChildren.Attributes.Add("width", "100%");

                    //var filteredGroup = GetDataDetailsByKey(parentKey);
                    var subGroupData = GetSubGroupData(parentKey, key);
                    var item         = ScheduleDetailDataManager.GetStatisticData(subGroupData, ScheduleDataModel.DataColumns.ScheduleTimeSpentConstant, ApplicationCommon.ScheduleStatisticUnknown);

                    var statisticControl = Page.LoadControl(ApplicationCommon.ScheduleStatisticControlPath) as ScheduleStatistics;
                    statisticControl.SetStatistics(parentKey, item);

                    detailContainer.Controls.Add(ctlDetailsWithChildren);
                    detailContainer.Controls.Add(statisticControl);

                    // add row for each sub grouping for statistic info tab
                    var subDiv = GetStatisticInfoHTMLRow(item, key, totalHoursWorkedForGroup, filteredGroup.Rows.Count);
                    mainDiv.Controls.Add(subDiv);

                    // add to tab control
                    tabControl.AddTab(key, detailContainer);

                    if (Page.IsPostBack)
                    {
                        ctlDetailsWithChildren.ShowData(false, true);
                    }
                }

                TableReportContent.Controls.Add(mainDiv);

                // add summary row for sub grouping for statistics info tab
                var ctrlStatSummary = GetStatisticInfoHTMLSummaryRow(filteredGroup, oSearchFilter.SubGroupBy);
                TableReportContent.Controls.Add(ctrlStatSummary);

                var seperator = new HtmlGenericControl("div");
                seperator.InnerHtml = "<br/>";
                TableReportContent.Controls.Add(seperator);

                if (detailsGridContainer != null)
                {
                    detailsGridContainer.Controls.Add(tabControl);
                }
            }
            else             // only Group By Case
            {
                // Add DetailsWithChildrenControl
                var ctlDetailsWithChildren = Page.LoadControl(ApplicationCommon.DetailsWithChildrenListControl) as DetailsWithChildrenControl;

                ctlDetailsWithChildren.ID = "oList";
                ctlDetailsWithChildren.SettingCategory = SettingCategory + "DetailsWithChildrenListControl";
                ctlDetailsWithChildren.IsFCModeVisible = false;
                ctlDetailsWithChildren.Setup("ScheduleDetail", "ScheduleDetail", "ScheduleDetailId", parentKey, true, GetDataDetailsByKey, GetColumns, "ScheduleDetail", DetailUserPreferenceCategoryId);
                ctlDetailsWithChildren.SetVisibilityOfListFeatures(false, false, false);
                ctlDetailsWithChildren.SetSession("true");
                ctlDetailsWithChildren.FieldConfigurationMode = ddlFieldConfigurationMode.SelectedValue;

                if (detailsGridContainer != null)
                {
                    detailsGridContainer.Controls.Add(ctlDetailsWithChildren);
                }

                if (Page.IsPostBack)
                {
                    ctlDetailsWithChildren.ShowData(false, true);
                }

                var statisticControlGroup = Page.LoadControl(ApplicationCommon.ScheduleStatisticControlPath) as ScheduleStatistics;
                //statisticControlGroup.SetStatistics(parentKey, statisticItem);

                if (detailsGridContainer != null)
                {
                    detailsGridContainer.Controls.Add(statisticControlGroup);
                }

                HtmlGenericControl ctrlStat = null;
                if (oSearchFilter.GroupBy == "-1")
                {
                    ctrlStat = GetStatisticInfoHTMLRow(statisticItem, parentKeyName, TotalTimeSpentCount, AllDataRows.Rows.Count);
                }
                else
                {
                    ctrlStat = GetStatisticInfoHTMLRow(statisticItem, parentKey, TotalTimeSpentCount, AllDataRows.Rows.Count);
                }

                //var ctrlStat = oSG.GetStatisticDataGrid(statisticItems, parentKey);
                TableReportContent.Controls.Add(ctrlStat);

                // check if all rows created, if yes then add, summary row in the end.
                if (TotalParentCount == GrdParentGrid.Items.Count + 1)
                {
                    var ctrlStatSummary = GetStatisticInfoHTMLSummaryRow(AllDataRows, oSearchFilter.GroupBy);
                    TableReportContent.Controls.Add(ctrlStatSummary);
                }
            }

            if (oSearchFilter.GroupBy == "-1")
            {
                oSC.Setup(parentKeyName, statisticItem);
            }
            else
            {
                oSC.Setup(parentKey, statisticItem);
            }
        }
        public void Should_bind_html()
        {
            var actual = new DataBinder<TestModel>().Html(m => m.Description).ToHtmlString();

            Assert.AreEqual(@"data-bind=""html: Description""", actual);
        }
Example #55
0
 protected void ListBox1_ItemDataBound(object sender, ListBoxItemEventArgs e)
 {
     e.Item.ImageUrl = "resources/images/products/" + DataBinder.Eval(e.Item.DataItem, "ImageName");
 }
        public void Should_bind_multiple_css()
        {
            var actual = new DataBinder<TestModel>().Css("hidden", m => m.IsActive).Css("chosen", m => !m.IsActive).ToHtmlString();

            Assert.AreEqual(@"data-bind=""css: { hidden: IsActive, chosen: !IsActive }""", actual);
        }
        /// <summary>
        /// Generates the templated column with the
        /// selection mode
        /// </summary>
        private void AnswersDataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            DataGridItem gridItem = (DataGridItem)e.Item;
            if (gridItem.ItemType != ListItemType.Footer && gridItem.ItemType != ListItemType.Header)
            {
                AnswerTypeData typeData = new AnswerTypes().GetAnswerTypeById(int.Parse(_answers.Answers[gridItem.DataSetIndex].AnswerTypeId.ToString()));
                gridItem.Cells[3].Text = GetPageResource(typeData.AnswerTypes[0].Description) != null ?
                    GetPageResource(typeData.AnswerTypes[0].Description) : typeData.AnswerTypes[0].Description;

                int typeMode = int.Parse(DataBinder.Eval(e.Item.DataItem, "TypeMode").ToString());
                bool ratePart = (bool)DataBinder.Eval(gridItem.DataItem, "RatePart");

                //				// Can this answer be selected ?
                if ((((AnswerTypeMode)typeMode & AnswerTypeMode.Selection) > 0))
                {
                    if (MultipleSelection)
                    {
                        CheckBox check = (CheckBox)gridItem.Cells[1].FindControl("DefaultCheckBox");
                        check.Checked = (bool)DataBinder.Eval(e.Item.DataItem, "Selected");
                        check.Visible = true;
                    }
                    else
                    {
                        GlobalRadioButton radio = (GlobalRadioButton)gridItem.Cells[1].FindControl("DefaultRadio");
                        radio.Checked = (bool)DataBinder.Eval(e.Item.DataItem, "Selected");
                        radio.Visible = true;
                    }

                    if (ratePart)
                    {
                        ((Label)gridItem.FindControl("RatingLabel")).Text = _currentRating.ToString();
                        _currentRating++;
                    }
                    else
                    {
                        ((Label)gridItem.FindControl("RatingLabel")).Text = "0";
                    }

                    if (_scoreEnabled)
                    {
                        if (DataBinder.Eval(e.Item.DataItem, "ScorePoint") != null &&
                            DataBinder.Eval(e.Item.DataItem, "ScorePoint").ToString().Length > 0)
                        {
                            ((Label)gridItem.FindControl("ScorePoint")).Text = DataBinder.Eval(e.Item.DataItem, "ScorePoint").ToString();
                        }
                        else
                        {
                            ((Label)gridItem.FindControl("ScorePoint")).Text = "0";
                        }
                    }
                }
                else
                {
                    gridItem.Cells[1].FindControl("DefaultRadio").Visible = false;
                    gridItem.Cells[1].FindControl("DefaultCheckBox").Visible = false;
                    ((Label)gridItem.FindControl("RatingLabel")).Text = "n/a";
                    ((Label)gridItem.FindControl("ScorePoint")).Text = "n/a";
                }
            }

        }