Monday, 31 December 2012

Resize or Reduce Dialog of jQuery UI DatePicker plugin using CSS

Dear all
Here is a new problem that all of us can we fix and after some time we forget how to do this again so i would  like to share it with all of you
which is how to increase or decrease the JQuery date picker dialog size thorough JQuery CSS class or our CSS class by the code below as it is

In our class

<style type = "text/css">
.ui-datepicker { font-size:9pt !important}
</style>
 
Or in the jQuery UI Calendar CSS file
.ui-datepicker { font-size:9pt !important}

Wednesday, 28 November 2012

.Net Business Connector Call a static method with dynamic parameters


Dear All
  Here a sample code for how to call a static method with a dynamic parameters because by default the CallStaticClassMethod allow you to only put max three parameters

so suppose we have a method in Axapta which is take two integer parameters and return the sum of them like this :


static int myMethod(int x,int y)
{
   Return x+y;
}

and here below is how to call this method with any number of parameters


            Dim param As Object() = New Object(1) {}
            param(0) = 3
            param(1) = 2       
            Return ax.CallStaticClassMethod("HBUnderQualityMovement", "myMethod", param)

Thanks and Regards
Happy Programming :)

Saturday, 17 November 2012

Convert English numbers into Arabic charchters

This artical is how to convert the English like 123456789 to ١٢٣٤٥٦٧٨٩٩٠


 public string ConvertToEasternArabicNumerals(string input)
        {
            System.Text.UTF8Encoding utf8Encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decoder = utf8Encoder.GetDecoder();
            System.Text.StringBuilder convertedChars = new System.Text.StringBuilder();
            char[] convertedChar = new char[1];
            byte[] bytes = new byte[] { 217, 160 };
            char[] inputCharArray = input.ToCharArray();
            foreach (char c in inputCharArray)
            {
                if (char.IsDigit(c))
                {
                    bytes[1] = Convert.ToByte(160 + char.GetNumericValue(c));
                    utf8Decoder.GetChars(bytes, 0, 2, convertedChar, 0);
                    convertedChars.Append(convertedChar[0]);
                }
                else
                {
                    convertedChars.Append(c);
                }
            }
            return convertedChars.ToString();
        }

Wednesday, 14 November 2012

View SSRS Report and passing parameters into it using report viewer ASP.NET

Dear All
As we like to make every thing is dynamic in this post i will show how to view a SSRS report published in the report server  using ASP.NET and also passing to it a parameters as the code below




        If Page.IsPostBack = False Then


            Try


                ReportViewer1.ServerReport.ReportServerCredentials = New ReportCredentials
                ReportViewer1.ShowCredentialPrompts = False
                ReportViewer1.ServerReport.ReportServerCredentials = New ReportCredentials()
                ReportViewer1.ProcessingMode = ProcessingMode.Remote

                Dim sReportName As String = "/budget/Budget_Actual"
                ReportViewer1.ServerReport.ReportServerUrl = New System.Uri("http://sv-ssrs01/Reportserver")
                ReportViewer1.ServerReport.ReportPath = sReportName

                ReportViewer1.ShowParameterPrompts = False


                ReportViewer1.ServerReport.SetParameters(New ReportParameter("BudgetYear", "2010"))
                ReportViewer1.ServerReport.SetParameters(New ReportParameter("BudgetYear2", "2012"))
                ReportViewer1.ServerReport.SetParameters(New ReportParameter("DepartmentID", "IT"))

                ReportViewer1.ServerReport.Refresh()

         

            Catch ex As Exception

            End Try


////////////////////////////////////////////////////////////////////////////////////


Public Class ReportCredentials
    Implements IReportServerCredentials
    Private _Username As String
    Private _Password As String
    Private _Domain As String

    Public Sub New()
        _Username = ConfigurationManager.AppSettings("ReportServerUserName").ToString
        _Password = ConfigurationManager.AppSettings("ReportServerPassword").ToString
        _Domain = ConfigurationManager.AppSettings("DOMAIN").ToString
    End Sub

    Public ReadOnly Property ImpersonationUser() As WindowsIdentity Implements IReportServerCredentials.ImpersonationUser
        Get
            Return Nothing
        End Get
    End Property

    Public ReadOnly Property NetworkCredentials() As System.Net.ICredentials Implements IReportServerCredentials.NetworkCredentials
        Get
            Return New Net.NetworkCredential(_Username, _Password, _Domain)
        End Get
    End Property

    Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, ByRef userName As String, ByRef password As String, ByRef authority As String) As Boolean Implements IReportServerCredentials.GetFormsCredentials
        userName = _Username
        password = _Password
        authority = _Domain
        Return Nothing
    End Function

End Class

Sunday, 9 September 2012

JQuery Loading animation in postback

Hi
I want to demonstrate in this article is how to make our web site is looking more attractive by putting an animation while loading the page in post back.

first we can create and design the loading animation from this website Here.

1- First we will create a simple button and do not forget to add the JQUERY reference classes like this.


<script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.7.2.js" type="text/javascript"></script>
<script src="Scripts/jquery.effects.core.js" type="text/javascript"></script>


2- put a simple button 
 <asp:Button ID="btnSearch" runat="server" Text="Search"  />

3-After creating and downloading the animation as a .gif image put it like this.


<div style="text-align: center; vertical-align: middle; font-family: Verdana; color: Blue;
                        position: absolute; top: 50%; left: 50%; margin-left: -88px; font-size: small;
                        background-color: White; border:2px solid #f90;" id="dvProgress" runat="server">
                        Please Wait ...
                        <img src="images/ajax-loader.gif" id="loader" style="vertical-align: middle;" alt="Processing" />
                    </div>

4-Put the below JQUERY code.


 <script type="text/javascript">


$(document).ready(function () {

    $('#dvProgress').hide();  // This is to hide the animation progress at first time


       $("#btnSearch").click(function () {     // show the animation progress upon we click the search button
       $("#dvProgress").show();      
   });   
      });
    </script>

Note: as we know that how is the IE is sucks you will find in all other browsers that the animation running perfectly except the IE so put this extra line of  code like this. 


        $("#dvProgress").show();
        setTimeout('document.images["loader"].src = "images/ajax-loader.gif"', 200);  



Happy Programming :)


Wednesday, 15 August 2012

Microsoft JScript runtime error: 'jQuery' is undefined

In  some cases  as we know the silly internet explorer gives us a weird errors as the tittle of this post, so after searching a lot of time please make sure while you adding the JQuery References class to put it like this (~/).


 <script src="~/Scripts/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>
 <script src="~/Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
 <script src="~/Scripts/jquery-1.7.2.js" type="text/javascript"></script> 

Instead of this

 <script src="Scripts/jquery-1.7.2.js" type="text/javascript"></script>

This error may appear or may be not just make sure to prevent any wasting time in the future 

Thursday, 9 August 2012

Enable and Disable controls by X++

Hi
In this post i will explain how to disable and enable controls in the form regarding to the business needs

Normal element control

    ControlName.Enabled(false); // Disable the control


Control Inside a grid or field

   TableName_ds.object(fieldnum(TableName,FieldName)).enabled(false);    //Disable the field