Sunday, December 28, 2014

Using Interface in Class

class Clsample    {
        #region Declarations

      
        ISample    l_SampleUpl;

        #endregion

        #region Constructor

        public ClsBankCodeFCCRMUpld( ISample    ISmplUpl)
        {
             l_SampleUpl = ISmplUpl;
        }





 public DataSet Fetchdata(out string l_errmsg)
        {
            ds = null;
            ArrayList ap = new ArrayList();
            ArrayList av = new ArrayList();
            try
            {
ap.add("FetchMode");
              av.Add( l_SampleUpl.l_FetchMode);
     ds = OracleDataAccess.oraExecProcRetDataset("pr_fetch_bankdet_fccrm", ap, av, out l_errmsg);
                return ds;
            }
            catch (Exception ex)
            {
                l_errmsg = ex.ToString();
                return ds;
            }

        }
}

 #region Interface
    public interface ISample    {
      
    }
    #endregion

Monday, July 11, 2011

How to filer the datatable using dataview using c#

Datatable dt = new Datatable ();
Datatable dtFilter = new Datatable ();OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.SelectCommand = cmd;
oleda.Fill(dt); //(Here you can Fill your datatable)
DataView dvRejFile = new DataView(dt);
//now you can filter the dataview using Row filter
// Column Name Value
dvRejFile1.RowFilter = "[Application No] <> '" + Pass your value+ "'";
// Assign your filter dataview to another datatable.
dtFilter = dvRejFile.ToTable();

Thursday, July 7, 2011

How to Read the Windows Form Names in c#

List GetFormNameList = new List();
Assembly asb = Assembly.GetExecutingAssembly();
foreach (Type type in asb.GetTypes())
{
if (type.BaseType.FullName.Equals("Common.UI.frmVirtual"))
{
GetFormNameList.Add(type.Name.ToString());
}
}

Thursday, June 24, 2010

How to create a Dynamic DataTable:

I have a requirement to create a dynamic data table for the shopping cart. When I search in Google I find some coding . I alter that coding change for my requirement.

Here you can create the data type and column name

private DataTable CreateDataTable()
{
DataTable myDataTable = new DataTable();

DataColumn myDataColumn;

myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Productname";
myDataTable.Columns.Add(myDataColumn);



myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.Decimal");
myDataColumn.ColumnName = "Quantity";
myDataTable.Columns.Add(myDataColumn);


myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.Decimal");
myDataColumn.ColumnName = "Productid";
myDataTable.Columns.Add(myDataColumn);





return myDataTable;
}



private void AddDataToTable(string PrdName, decimal Qty,decimal id, DataTable myTable)
{
DataRow row;

row = myTable.NewRow();


row["Productname"] = PrdName;

row["Quantity"] = Qty;

row["Productid"] = id;


myTable.Rows.Add(row);

}


Remove the duplicates from datatable

private static void RemoveDuplicates(DataTable tbl,

DataColumn[] keyColumns)
{

int rowNdx = 0;

while (rowNdx < tbl.Rows.Count - 1) { DataRow[] dups = FindDups(tbl, rowNdx, keyColumns); if (dups.Length > 0)
{

foreach (DataRow dup in dups)
{

tbl.Rows.Remove(dup);

}

}

else
{

rowNdx++;

}

}

}




private static DataRow[] FindDups(DataTable tbl,

int sourceNdx,

DataColumn[] keyColumns)
{

ArrayList retVal = new ArrayList();



DataRow sourceRow = tbl.Rows[sourceNdx];

for (int i = sourceNdx + 1; i < tbl.Rows.Count; i++) { DataRow targetRow = tbl.Rows[i]; if (IsDup( targetRow,sourceRow, keyColumns)) { retVal.Add(sourceRow); } } return (DataRow[])retVal.ToArray(typeof(DataRow)); } private static bool IsDup(DataRow sourceRow, DataRow targetRow,DataColumn[] keyColumns) { bool retVal = true; foreach (DataColumn column in keyColumns) { retVal = retVal && sourceRow[column].Equals(targetRow[column]); if (!retVal) break; } return retVal; }


/* Here you can pass the values to create a row */

AddDataToTable(strname, txtid, decimal.Parse(strprodid), (DataTable)Session["myDatatable"]);


/* remove the duplicate from datatable */
DataTable Dtcount = new DataTable();

Dtcount = (DataTable)Session["myDatatable"];

DataColumn[] keyColumns = new DataColumn[]
{Dtcount.Columns[2], Dtcount.Columns[2]};

RemoveDuplicates(Dtcount, keyColumns);

Here I can bind the Datatable values in datalist to show the shopping cart.

In that datalist I use text box to update the quantity.

In the txt_TextChanged I write the coding to update the data table.


TextBox tb1 = ((TextBox)(sender));

DataListItem rp1 = ((DataListItem)(tb1.NamingContainer));
string strProductId = rp1.ItemIndex.ToString();

string strUniqeID = datalist1.DataKeys[rp1.ItemIndex].ToString();

/* Here your logic */

Dtcount = (DataTable)Session["myDatatable"];

Dtcount.DefaultView[int.Parse(strProductId)]["Quantity"] = decimal.Parse(strId);

Dtcount.DefaultView[int.Parse(strProductId)]["Price"] = decPrice;

Session["myDatatable"] = Dtcount;

/* Here u can bind the datalist */


/* Delete the particular row in datatable */
/* I write the coding in datalist1_DeleteCommand to delete a particular row */




DataRow dr = ((DataTable)Session["NewDatatable"]).Rows[e.Item.ItemIndex];
dr.Delete();
((DataTable)Session["NewDatatable"]).AcceptChanges();

/* Here u can bind the datalist */

Sunday, May 23, 2010

Keyboard Shortcuts in SQL Server


• Starting the SQL Server management studio Go to Start > Run and type the following command SQLWB
• To see the Object explorer press F8.
• To parse a Query you have written, press Ctrl + F5
• To Execute a Query, press F5 ( before executing you should always parse the query)
• Use F4 for properties window.
• You have options to show the output in Grid (default) or in Text format, Ctrl + D and Ctrl + T respectively) and I you want to output the results to a file use the combination Ctrl + Shift + F
• Ctrl + Shift + Q will display the Query Designer window.
• Display the execution plan using Ctrl + L, It is an advanced topic that we will cover later.
• Use Ctrl + K followed by Ctrl + C to comment out selected lines of code. Use Ctrl + K followed by Ctrl + U to uncomment the selection.
• Use Ctrl + Shift + U to make the selection Uppercase and use Ctrl + Shift + L to change it back to lower case
• Another common requirement is word wrapping for long queries, you may use the combination Ctrl + E followed by Ctrl + W
• Shift + Alt + Enter can be used to toggle between a full screen mode and a normal one.

Saturday, April 10, 2010

How to Access Master page Function into Content Page


In Masterpage  you can write the Function


public void showall()
{
 /* .....Your code goes here */
}

In content page
  in the Design window source add this code

<%@ MasterType VirtualPath="Masterpage Name" %>


after that in codebehind file you can access like this

master.showall();

now you can access the masterpage function in  contentpage..

Saturday, August 22, 2009

How to change the Master Pages  in runtime....
1st add one column in ur table... name as varThemename (varchar(150))



then u can add this code to where ur masterpage is going to change




protected override void OnPreInit(EventArgs e)
{



string ThemeName;

cmd.commandtype=commandtype.text;
commandtype.text="select varTheme name from table name where id="1;


ThemeName= cmd.executescalar().tostring();






string masterfile = ThemeName;

if (!masterfile.Equals(string.Empty))
{
base.MasterPageFile = masterfile;
}
base.OnPreInit(e);
}
else
{
// Your Logik
}
}