27 Haziran 2013 Perşembe

Android Socket programming connection failed

if there  is connection failed on your app you must run this command from console

                    adb forward tcp:8080 tcp:8080

each of this tcp:8080 is your server port and client port number.



1 Haziran 2013 Cumartesi

DEVEXPRESS Use Cascade Combobox in İnline Edit Mode

<dx:GridViewDataComboBoxColumn FieldName="Category1ID" VisibleIndex="4">
                    <PropertiesComboBox DataSourceID="dsCategory1" TextField="Name" ValueField="ID" ValueType="System.Int32">
                    </PropertiesComboBox>
                    <EditItemTemplate>
                            <dxe:ASPxComboBox ID="Cat1" runat="server"
                            DataSourceID="dsCategory1"  TextField="Name" ValueField="ID" Value='<%# Bind("Category1ID") %>'
                            AutoPostBack="true" OnSelectedIndexChanged="Cat1_SelectedIndexChanged" ValueType="System.Int32">
                            </dxe:ASPxComboBox>
                    </EditItemTemplate>
                </dx:GridViewDataComboBoxColumn>

------------------------------------------------------------------------------------------------------------

protected void grid_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if ((e.RowType == GridViewRowType.InlineEdit)) {
                ASPxComboBox combo2 = ((ASPxComboBox)grid.FindEditRowCellTemplateControl(
                    grid.Columns["Category2ID"] as GridViewDataComboBoxColumn, "Cat2"));
                if (Request.Params[combo2.UniqueID] != null) return;

                if (!grid.IsNewRowEditing) {
                    object[] vals = (object[])grid.GetRowValues(grid.EditingRowVisibleIndex,
                    new string[] { "Category2ID", "Category3ID", "Category4ID" });
                    ASPxComboBox combo4 = ((ASPxComboBox)grid.FindEditRowCellTemplateControl(
                    grid.Columns["Category4ID"] as GridViewDataComboBoxColumn, "Cat4"));
                    ASPxComboBox combo3 = ((ASPxComboBox)grid.FindEditRowCellTemplateControl(
                    grid.Columns["Category3ID"] as GridViewDataComboBoxColumn, "Cat3"));
                    combo2.Value = vals[0];
                    combo3.Value = vals[1];
                    combo4.Value = vals[2];
                }
            }
        }

31 Mayıs 2013 Cuma

DEVEXPRESS ASPxGridView PropertiesComboBox DataSource On CodeBehind

<dx:ASPxGridView ID="GridViewTRY" runat="server"  DataSourceID="SDSGridViewTRY" KeyFieldName="ID" OnInit="GridViewTRY_Init">
        <Columns>                                  
              <dx:GridViewDataComboBoxColumn FieldName="PersonalFK" Caption="Personel Adı" ShowInCustomizationForm="True" >
                      <PropertiesComboBox TextField="PersonelName" ValueField="ID"></PropertiesComboBox>
                       </dx:GridViewDataComboBoxColumn>            
          </Columns>
</dx:ASPxGridView>

                           //                        on CodeBehind             //                          

protected void GridViewTRY_Init(object sender, EventArgs e)
{
   ASPxGridView gridView = (ASPxGridView)sender;
   ((GridViewDataComboBoxColumn)(gridView.Columns["PersonelFK"])).PropertiesComboBox.DataSource = myPersonalList;
}

30 Mayıs 2013 Perşembe

pass null parameter if Selectparameter is null

<asp:SqlDataSource ID="SDStry" runat="server" CancelSelectOnNullParameter="false"
SELECTCommand="SELECT  * FROM tbFirma WHERE KisiFK=ISNULL(@KisiFK,KisiFK)">

<SelectParameters>
        <asp:Parameter Name="KisiFK" ConvertEmptyStringToNull="true" />
</SelectParameters>

</asp:SqlDataSource>

2 Mayıs 2013 Perşembe

create special Sorting with c#



public class SortByNumber : Comparer<object>
{

    public override int Compare(object x, object y)
    {

        var xParts = x.GetType().GetProperty("Code").GetValue(x, null).ToString().Split(new[] { '.' });
        var yParts = y.GetType().GetProperty("Code").GetValue(y, null).ToString().Split(new[] { '.' });

        xParts = xParts.Select((c) => { return (c == "" ? "0" : c); }).ToArray();
        yParts = yParts.Select((c) => { return (c == "" ? "0" : c); }).ToArray();

        int index = 0;
        while (true)
        {
            bool xHasValue = xParts.Length > index;
            bool yHasValue = yParts.Length > index;
            if (xHasValue && !yHasValue)
                return 1;   // x bigger
            if (!xHasValue && yHasValue)
                return -1;  // y bigger
            if (!xHasValue && !yHasValue)
                return 0;   // no more values -- same
           
            var xValue = int.Parse(xParts[index]);
            var yValue = int.Parse(yParts[index]);

            if (xValue > yValue)
                return 1;   // x bigger
            if (xValue < yValue)
                return -1;  // y bigger
            index++;
        }
    }

        }

//*******//

     
        public class ctry { public string Code{ get; set; }}
        public void tryTest()
        {
         
            List<ctry> cList = new List<ctry>();

            cList.Add(new ctry() { Code= "1.1" });
            cList.Add(new ctry() { Code = "5" });
            cList.Add(new ctry() { Code = "1.5" });
            cList.Add(new ctry() { Code = "1.2" });
            cList.Add(new ctry() { Code = "1.1.2" });
            cList.Add(new ctry() { Code = "1" });
            cList.Add(new ctry() { Code = "1.1.1" });
            cList.Add(new ctry() { Code = "1.11" });
            cList.Add(new ctry() { Code = "1.4" });
            cList.Add(new ctry() { Code = "6" });


            cList.Sort(new SortComparer ());
         
        }
         

23 Kasım 2012 Cuma

mvc de $.ajax() ile multi delete


function f_MultiDelete()
{
if ($(".chList").size() > 0) {
            var IDS = [];

            $(".chList").each(function (i) {
                if ($(this).attr('checked') == "checked" && $(this).attr('name') == "checkDelete") {
                    var ID = $(this).attr("vl");
                    IDS.push(ID);
                }
            });
            if (IDS.length > 0) {
                $.ajax({
                    type: "POST",url: Path,

                    traditional:true,
                    dataType:"json",
                    data: { 'IDList': IDS },
                    success: function (data) {
                        alert(data);
                    }
                });
            }
        }
}

<input name="checkDelete" class="chList" vl="4" type="checkbox" />
<input name="checkDelete" class="chList" vl="3" type="checkbox" />
<input name="checkDelete" class="chList" vl="2" type="checkbox" />
<input name="checkDelete" class="chList" vl="5" type="checkbox" />

<div onclick="f_MultiDelete('/Admin/AGaleri/MultiDelete/')" class="btn btn-primary">Seçilileri Sil </div>




public ActionResult MultiDelete(IEnumerable<string> IDList)
{
    //IDList parametresinden seçili ID lere ulaşabilirsiniz.
}

24 Ekim 2012 Çarşamba

asp.nette web servis kullanımı

Şimdilik .net 3.5 ta web servisi oluşturabiliyoruz. .net4.0 henüz desteklemiyor

    public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }


        [WebMethod]
        public bool firstService(string name,string lastName)
        {
            // yazmak istediğimiz kodlar           
        }

        // webmethod fonksiyonlarımız istediğimiz kadar çoğaltabiliriz.
    }



Web servisini projemize 'tryWebService' adında ekliyoruz
            
        var service1 = new tryWebService.Service1SoapClient();
        service1.firstService("parametre1", "parametre2");

 // yazdığımız tüm methodlara service1 örneğinden ulaşabiliriz.