Translate

Home > May 2011

May 2011

Panel Show Hide, On Off , Easing

Monday, May 23, 2011 Category : , 0

Write this In your MXML File

  <mx:Move id="panelOut" target="{panel}" xTo="0" effectEnd="btn.label='Close'"
        duration="1500" easingFunction="Bounce.easeOut"/>
    <mx:Move id="panelIn" target="{panel}" xTo="-230" effectEnd="btn.label='Open'"
        duration="1000" easingFunction="Bounce.easeIn"/>


    <mx:Canvas id="panel" width="250" height="50%" backgroundColor="#F79A9A" verticalCenter="69">
    <!--Add the content of your sliding panel here  -->
    <mx:HBox width="100%" height="100%">
        <mx:Accordion id="myAccor" height="100%" width="100%">
            <mx:Form label="A" width="100%" height="100%">
            </mx:Form>
            <mx:Canvas label="B" width="100%" height="100%">
            </mx:Canvas>
            <mx:Canvas label="C" width="100%" height="100%">
            </mx:Canvas>
            <mx:Canvas label="D" width="100%" height="100%">
            </mx:Canvas>

        </mx:Accordion>
        <mx:Button id="btn" width="20" height="100%" right="0" label="Open" click="toggleBtn(event)">
        </mx:Button>
    </mx:HBox>
---------------------------------------------------------------------------------------
        import mx.effects.easing.*;

            private function toggleBtn(e:MouseEvent):void{
                if(e.currentTarget.label== 'Open')
                    panelOut.play();
                else
                    panelIn.play();
            }

<!--Other Easing Function are :
1. Back.easeIn
2. Bounce.easeIn
3. Circular.easeIn
4. Cubic.easeIn
5. Elastic.easeIn
6. Exponential.easeIn
7. Linear.easeIn
8. Quadratic.easeIn
9. Quartic.easeIn
10. Quintic.easeIn
11. Sine.easeIn
-->

Flex Get DataGrid Row Value one bye one

Sunday, May 22, 2011 Category : , 0

        private function getDataGridValue():Array {

            var columnsValue:Array = new Array();
            var column:DataGridColumn;
            var dataProvider:Object = view.dataGrid.dataProvider;
            var rowCount:int = dataProvider.length;

            var ColumnValue:String;
            for(var i:int=0;i<rowCount;i++)
            {
                column = view.dataGrid.columns[3];
                ColumnValue = column.itemToLabel(dataProvider[i]);
                columnsValue.push(ColumnValue);
            }
            return columnsValue;
            //Alert.show(ColumnValue);
        }

Flex Yes no Example

Category : , 0

private var alert:Alert;

alert = Alert.show("This will remove all loaded template", "Warning!", Alert.YES | Alert.NO);
                    alert.addEventListener(CloseEvent.CLOSE, normalDesignAlert_close);


private function normalDesignAlert_close(evt:CloseEvent):void {
                switch (evt.detail) {
                    case Alert.NO:
                        selectApporpriateRadioButton();
                        break;
                    case Alert.YES:
                        view.lblDesignType.text = NormalTemplateDesign;
                        view.dataGrid.dataProvider = null;
                        rows = null;
                        TemplateFilter = "*.skdn";
                        break;
                }
            }

Flex DataGrid Example for Image

Thursday, May 19, 2011 Category : , 0

Use this code on your mxml File

<mx:DataGrid width="90%"
            height="90%"
            id="dataGrid">
            <mx:columns>
                <mx:DataGridColumn dataField="_designIcon"
                    headerText="Design Icon">
                    <mx:itemRenderer>
                        <mx:Component>
                        <mx:HBox horizontalAlign="center" height="84">
                        <mx:Image source="{data._designIcon}"/>
                        </mx:HBox>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
                <mx:DataGridColumn dataField="_designName"
                    headerText="Design Name" />
                <mx:DataGridColumn dataField="_designDataSize"
                    headerText="Design Data Size(MB)" width="200" />
                <mx:DataGridColumn dataField="_designLocation"
                    headerText="Design Local Path" />
                <mx:DataGridColumn headerText="Delete Item">
                <mx:itemRenderer>
                    <mx:Component>
                    <mx:LinkButton label="Delete" click="outerDocument.deleteItem(event)"/>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>


Use this code into mx:script tag

private var rows:ArrayCollection;
rows.addItem(new PackageRowInfo(IconLocation, contentType,fileSize ,path));


for packageRowInfo class use following code
public class PackageRowInfo
    {
        public var _designIcon:String;

        public var _designName:String;

        public var _designDataSize:String;

        public var _designLocation:String;

        public function PackageRowInfo(designIcon:String,designName:String,designDataSize:String,designLocation:String)
        {
            _designIcon = designIcon;
            _designName = designName;
            _designDataSize = designDataSize;
            _designLocation = designLocation;
        }

    }

Flex Adobe Air get Mac Address

Thursday, May 12, 2011 Category : 5

var networkInterface : Object =  NetworkInfo.networkInfo.findInterfaces();
var networkInfo  : Object = networkInterface[0];
var physicalAddress : String = networkInfo.hardwareAddress.toString();

Packaging a desktop native installer

Wednesday, May 11, 2011 Category : 0

run cmd

then type ->  cd D:\Program Files\Adobe\Flex Builder 3 Plug-in\sdks\3.5\bin


Command :
adt -package -target native -storetype pkcs12 -keystore Personal Information Exchange output.exe input.air



where : Personal Information Exchange is an .p12 file which you can build when making and air file.

Example:
adt -package -target native -storetype pkcs12 -keystore C:\Workspace_Sharaku\SharakuPremium\Sharaku.p12 C:\Workspace_Sharaku\SharakuPremium\app.exe C:\Workspace_Sharaku\SharakuPremium\SharakuPremium.air

C# Using Error Provider

Sunday, May 1, 2011 Category : 0

private bool saveFlag =true;
        bool addnewFlag =false;


duplicateCheck();
                if (saveFlag)
                {



        }



public void duplicateCheck()
        {
            if (addnewFlag)
            {
                DAL.DataSetErrotProviderTableAdapters.item_catagoryTableAdapter AdapterCategory = new Hardware_Inventory.DAL.DataSetErrotProviderTableAdapters.item_catagoryTableAdapter();
                DataTable dt = AdapterCategory.GetData(item_catagory_nameTextBox.Text);
                if (dt.Rows.Count > 0)
                {
                    errorProvider1.SetError(item_catagory_nameTextBox, "This Name Allready Enter In Database");
                    saveFlag = false;
                }
                else if (dt.Rows.Count == 0)
                {
                    errorProvider1.SetError(item_catagory_nameTextBox, "");
                    saveFlag = true;
                }
            }
        }

C# Data Encryption

Category : 0

 Using System.Security.Cryptography


        private static TripleDESCryptoServiceProvider cryptDES3 = new TripleDESCryptoServiceProvider();
        private static MD5CryptoServiceProvider cryptMD5Hash = new MD5CryptoServiceProvider();


        #region crypto functions

        /// <summary>
        /// function to decrypt a phrase
        /// </summary>
        public static string Decrypt(string phrase)
        {
            string encodedPhrase;
            byte[] Buff;

            cryptDES3.Key = cryptMD5Hash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(phrase));
            cryptDES3.Mode = CipherMode.ECB;
            ICryptoTransform desdencrypt = cryptDES3.CreateDecryptor();       
            Buff = Convert.FromBase64String(phrase);
            encodedPhrase = ASCIIEncoding.ASCII.GetString(desdencrypt.TransformFinalBlock(Buff, 0, Buff.Length));

            return encodedPhrase;
        }

        /// <summary>
        /// function to encrypt a phrase
        /// </summary>
        public static string Encrypt(string phrase)
        {
            string decodedPhrase;
            byte[] Buff;

            cryptDES3.Key = cryptMD5Hash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(phrase));
            cryptDES3.Mode = CipherMode.ECB;
            ICryptoTransform desdencrypt = cryptDES3.CreateDecryptor();
            Buff = ASCIIEncoding.ASCII.GetBytes(phrase);
            decodedPhrase = Convert.ToBase64String(desdencrypt.TransformFinalBlock(Buff, 0, Buff.Length));

            return decodedPhrase;
        }

        #endregion

C# Dataset To DataTable Conversion

Category : 0

AccountDataSet.CHART_OF_ACCDataTable cT = new AccountDataSet.CHART_OF_ACCDataTable();
           DAL.AccountDataSetTableAdapters.CHART_OF_ACCTableAdapter cAdapter = new AccountingDigitalOptimize.DAL.AccountDataSetTableAdapters.CHART_OF_ACCTableAdapter();
            cT.TableName = "Accounts";
           cAdapter.Fill(cT);



           /DataSet ds = new DataSet();
           ds.Tables.Add(cT);
           
           
           DataTableReader dReader = ds.CreateDataReader();
          ds.Load(dReader, LoadOption.OverwriteChanges, cT);

c# Custom DataTable and Dataset

Category : 0

private System.Data.DataSet dataSet;

private void MakeDataTables()
{
    // Run all of the functions.
    MakeParentTable();
    MakeChildTable();
    MakeDataRelation();
    BindToDataGrid();
}

private void MakeParentTable()
{
    // Create a new DataTable.
    System.Data.DataTable table = new DataTable("ParentTable");
    // Declare variables for DataColumn and DataRow objects.
    DataColumn column;
    DataRow row;

    // Create new DataColumn, set DataType,
    // ColumnName and add to DataTable.   
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "id";
    column.ReadOnly = true;
    column.Unique = true;
    // Add the Column to the DataColumnCollection.
    table.Columns.Add(column);

    // Create second column.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.String");
    column.ColumnName = "ParentItem";
    column.AutoIncrement = false;
    column.Caption = "ParentItem";
    column.ReadOnly = false;
    column.Unique = false;
    // Add the column to the table.
    table.Columns.Add(column);

    // Make the ID column the primary key column.
    DataColumn[] PrimaryKeyColumns = new DataColumn[1];
    PrimaryKeyColumns[0] = table.Columns["id"];
    table.PrimaryKey = PrimaryKeyColumns;

    // Instantiate the DataSet variable.
    dataSet = new DataSet();
    // Add the new DataTable to the DataSet.
    dataSet.Tables.Add(table);

    // Create three new DataRow objects and add
    // them to the DataTable
    for (int i = 0; i<= 2; i++)
    {
        row = table.NewRow();
        row["id"] = i;
        row["ParentItem"] = "ParentItem " + i;
        table.Rows.Add(row);
    }
}

private void MakeChildTable()
{
    // Create a new DataTable.
    DataTable table = new DataTable("childTable");
    DataColumn column;
    DataRow row;

    // Create first column and add to the DataTable.
    column = new DataColumn();
    column.DataType= System.Type.GetType("System.Int32");
    column.ColumnName = "ChildID";
    column.AutoIncrement = true;
    column.Caption = "ID";
    column.ReadOnly = true;
    column.Unique = true;

    // Add the column to the DataColumnCollection.
    table.Columns.Add(column);

    // Create second column.
    column = new DataColumn();
    column.DataType= System.Type.GetType("System.String");
    column.ColumnName = "ChildItem";
    column.AutoIncrement = false;
    column.Caption = "ChildItem";
    column.ReadOnly = false;
    column.Unique = false;
    table.Columns.Add(column);

    // Create third column.
    column = new DataColumn();
    column.DataType= System.Type.GetType("System.Int32");
    column.ColumnName = "ParentID";
    column.AutoIncrement = false;
    column.Caption = "ParentID";
    column.ReadOnly = false;
    column.Unique = false;
    table.Columns.Add(column);

    dataSet.Tables.Add(table);

    // Create three sets of DataRow objects,
    // five rows each, and add to DataTable.
    for(int i = 0; i <= 4; i ++)
    {
        row = table.NewRow();
        row["childID"] = i;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 0 ;
        table.Rows.Add(row);
    }
    for(int i = 0; i <= 4; i ++)
    {
        row = table.NewRow();
        row["childID"] = i + 5;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 1 ;
        table.Rows.Add(row);
    }
    for(int i = 0; i <= 4; i ++)
    {
        row = table.NewRow();
        row["childID"] = i + 10;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 2 ;
        table.Rows.Add(row);
    }
}

private void MakeDataRelation()
{
    // DataRelation requires two DataColumn
    // (parent and child) and a name.
    DataColumn parentColumn =
        dataSet.Tables["ParentTable"].Columns["id"];
    DataColumn childColumn =
        dataSet.Tables["ChildTable"].Columns["ParentID"];
    DataRelation relation = new
        DataRelation("parent2Child", parentColumn, childColumn);
    dataSet.Tables["ChildTable"].ParentRelations.Add(relation);
}

private void BindToDataGrid()
{
    // Instruct the DataGrid to bind to the DataSet, with the
    // ParentTable as the topmost DataTable.
    dataGrid1.SetDataBinding(dataSet,"ParentTable");
}

C# get DataGrid Combobox Selected Value

Category : 0

 DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)datagridControlSupplier[2,e.RowIndex];
MessageBox.Show(cell.Value.ToString());

c# gridView Column Color Change

Category : 0

dataGridView1.Columns[3].DefaultCellStyle.Font = new Font("Microsoft Sans Serif", 24.5F, GraphicsUnit.Pixel);

c# cookie Management

Category : 0

using System;
using System.Data;
using System.Web;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(Request.Cookies["BackgroundColor"] != null)
        {
            ColorSelector.SelectedValue = Request.Cookies["BackgroundColor"].Value;
            BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
        }
    }

    protected void ColorSelector_IndexChanged(object sender, EventArgs e)
    {
        BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
        HttpCookie cookie = new HttpCookie("BackgroundColor");
        cookie.Value = ColorSelector.SelectedValue;
        cookie.Expires = DateTime.Now.AddHours(1);
        Response.SetCookie(cookie);
    }
}

C# get gridView all row value

Category : 0

foreach (GridViewRow gvr in GridView1.Rows)   //loop through GridView
        {
            OleDbConnection conn = new OleDbConnection("your_connectionstring");
            //suppose ItemCode is in the first column and Quantity is in the third column of GridView
            OleDbCommand cmd = new OleDbCommand("insert into [QDETAILS](ItemCode,Quantity) values (" + gvr.Cells[0].Text + ",'" + gvr.Cells[2].Text + "')", conn);
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
        }

C# get GridView Selected Row

Category : 1

        protected void gvItemGrid_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow gRow = gvItemGrid.SelectedRow;
            lblID.Text = gRow.Cells[1].Text;
            lblName.Text = gRow.Cells[2].Text;

        }

c# change App.config files Connection String

Category : 0

using System.Configuration;

string newConnectionString1 = "Data Source=" + txtServer.Text + ";Initial Catalog=Garments;Persist Security Info=True;User ID=" + txtLogin.Text +";Password="+ txtPass.Text;


 string newConnectionString2 = "Data Source=" + txtServer.Text + ";Initial Catalog=Garments;Persist Security Info=True;User ID=" + txtLogin.Text + ";Password=" + txtPass.Text;
           

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.ConnectionStrings.ConnectionStrings["Germens_production.Properties.Settings.GermensConnectionString"].ConnectionString = newConnectionString1;
            config.ConnectionStrings.ConnectionStrings["Germens_production.Properties.Settings.GarmentsConnectionString"].ConnectionString = newConnectionString2;

config.Save(ConfigurationSaveMode.Modified, true);
            ConfigurationManager.RefreshSection(config.ConnectionStrings.SectionInformation.SectionName);

Powered by Blogger.