Monday, 4 August 2014

Auto Complete Show any Names in C#.net


private void AutoCompleteMachine(object sender, KeyPressEventArgs e)
        {
            string strFindstr = "";
            if (e.KeyChar == 8)
            {
                if (cbxMname.SelectionStart <= 1)
                {
                    cbxMname.Text = "";
                    return;

                }
                if (cbxMname.SelectionLength == 0)
                    strFindstr = cbxMname.Text.Substring(0, cbxMname.Text.Length - 1);
                else
                    strFindstr = cbxMname.Text.Substring(0, cbxMname.SelectionStart - 1);

            }
            else
            {
                if (cbxMname.SelectionLength == 0)
                    strFindstr = cbxMname.Text + e.KeyChar;
                else
                    strFindstr = cbxMname.Text.Substring(0, cbxMname.SelectionStart) + e.KeyChar;

            }
            int intIndex = -1;
            intIndex = cbxMname.FindString(strFindstr);
            if (intIndex != -1)
            {
                cbxMname.SelectedText = "";
                cbxMname.SelectedIndex = intIndex;
                cbxMname.SelectionStart = strFindstr.Length;
                cbxMname.SelectionLength = cbxMname.Text.Length;
                e.Handled = true;
            }
        }

How to Update Datagridview in C#


 private void PurDgvintoItemsEntryUpdate()
        {

            int rc = dgvPurchase.Rows.Count - 1;
            if (rc > 0)
            {
                for (int i = 0; i < rc; i++)
                {
                   // string pno = cbxBillNo.Text;
                    string itemtype = dgvPurchase[1, i].Value.ToString();
                    string itname = dgvPurchase[2, i].Value.ToString();
                    // string product = dgvBilling1[2, i].Value.ToString();
                    string Batchno = dgvPurchase[3, i].Value.ToString();
                    string MRP = dgvPurchase[9, i].Value.ToString();
                    string SellPers = dgvPurchase[17, i].Value.ToString();
                    string SellAmt = dgvPurchase[19, i].Value.ToString();
                    double  SellMorAmt =Convert .ToDouble ( dgvPurchase[18, i].Value.ToString());
                    double  BasicRate =Convert .ToDouble ( dgvPurchase[12,i].Value.ToString());
                    double  VatPers =Convert .ToDouble ( dgvPurchase[13, i].Value.ToString());
                    double netcost =Convert.ToDouble ( dgvPurchase[8, i].Value.ToString());
                    double  DiscPers =Convert .ToDouble ( dgvPurchase[10, i].Value.ToString());
                    double DiscAmt =Convert .ToDouble ( dgvPurchase[11, i].Value.ToString());
                    double TransPers =Convert .ToDouble ( dgvPurchase[15, i].Value.ToString());
                    double DummyRate = Convert.ToDouble(dgvPurchase[20, i].Value.ToString());
                    string TStrength = dgvPurchase[26, i].Value.ToString();
                    string unitss = dgvPurchase[25, i].Value.ToString();
                    string maxqty = dgvPurchase[23, i].Value.ToString();
                    string minqty = dgvPurchase[24, i].Value.ToString();

                    // To Update Item Master Table
                    //ID IDs Mname ItemName MRP PurRate PurTax PurTotAmt SalesPers SalesTotAmt SalesMor DiscoPers DiscoAmt TransPers TotQty Units MaxQty MinQty DummyRate

                    string str = "Update T_ITEMSCOLLECTION Set MRP='"+MRP+"',PurRate='" + BasicRate + "',PurTax='" + VatPers + "',PurTotAmt='" + netcost + "',SalesPers='" + SellPers + "',SalesTotAmt='" + SellAmt + "',SalesMor='" + SellMorAmt + "',DiscoPers='" + DiscPers + "',DiscoAmt='" + DiscAmt + "',TransPers='" + TransPers + "',TotQty='" + TStrength + "',Units='" + unitss + "',MaxQty='" + maxqty + "',MinQty='" + minqty + "',DummyRate='" + DummyRate + "' where Mname='" + itemtype + "' and ItemName='" + itname + "'";// and ItemNo='" + partno + "'";//ID=" + cbxItemId.Text + "";                     
                        con = new OleDbConnection(dbCon());
                        OleDbCommand cmd = new OleDbCommand(str, con);
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                       MessageBox.Show("Purchase Rates Updated", "Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }


        }

Microsoft Sql Server



Sql Server is a relational database management system (RDBMS) 
developed by Microsoft that's designed for the enterprise environment.
It is a software product whose primary function is to store and retrieve
 data as requested by other software application.The original sql server 
code was developed by sybase in the late 1980.
The first version of sql server was sql server 4.2.The latest version of sql 
server is sql server 2012.
Create Database Through Sql command:-
SYNTAX:-

 create database database Name

EX:-   create database rsv


Create table in database:-

SYNTAX:-
create table table Name (column1 data type,column2 data type, column3 data type)

EX:-   create table student(sid int, sname varchar(30),sage int)


Insert Data in table :-
SYNTAX:-
insert into table Name values(value1,value2,value3)
OR
insert into  table Name ( column1 , column2 , column3 )
values( value1,value2,value3 )
OR
insert  table Name values( value1,value2,value3 )

EX:-
insert into student values(101,'vinod',22)
OR
insert into student(sname,sid,sage)values('neha',102,22)
OR
insert student values(103,'manoj',21)

NOTE:-Here 'INTO' is optional.

Fetch the value from database table:-
SYNTAX:-
select*from table Name

EX:- select*from student


Update Existing Records in the Table:-

SYNTAX:-  update Table Name set column1=value,column2=value 
 where column3=value

EX:- update student set sname='ram',sage=25  where sid=103


Delete the record from the table:-
SYNTAX:-
delete from table Name where column =value

EX: delete from student where sid=103


Note:-  After the "WHERE" Clause we give the some condition,if any column
 have primary or unique key then we use that column after the " WHERE ".
Here we have not specified any primary key or unique key , we will discuss it soon.

Add New Column In Existing Table:-
SYNTAX:-
alter table table Name add column data type

EX:-
alter table student add saddress varchar(40)


Change the Size of Existing Column in the Table:-

SYNTAX:-
alter table  table Name  alter column column Name data type

EX:-
alter table student alter column saddress varchar(80)

Drop The Existing Column from the Table:-
SYNTAX:-
alter table  table Name  drop column column Name
EX:-
alter table student drop column saddress


Change The Column Name In Existing Table:-
SYNTAX:-
sp_rename 'tableName.oldcolumnName','NewColumnName','column'

EX:-
sp_rename 'student.sage','s_age','column'


Change The Existing Table:-

SYNTAX:-
sp_rename ' oldtable Name ',' Newtable Name ','object'

EX:-
sp_rename 'student','studentdetails','object'


To Know the Structure of Database Table:-

SYNTAX:- 
sp_help table Name

EX:-

sp_help studentdetails

How to Delete a table:-
SYNTAX:-
Drop table Table Name
EX:-
Drop table studentdetails

Summary of accounts using C#.NET


 private void FromToDateChange()
        {
            crystalReportViewer1.Cursor = Cursors.WaitCursor;
            progressBar1.Visible = true;
            progressBar1.BringToFront();
            Cursor.Current = Cursors.WaitCursor;
            rptCustDayBook cr1 = new rptCustDayBook();
            DataSet ds = new DataSet();
            int count = 0;
            string sTot = "";
            double totSale = 0.00;
            lblNetAmt.Text = "";
            DateTime dFrdt = DateTime.Parse(dtpFrTotsale.Text);
            //Convert Date Format of(dd/mm/yyyy)
            string fdd = dFrdt.Day.ToString();
            string fmm = dFrdt.Month.ToString();
            string fyyyy = dFrdt.Year.ToString();
            string sFrdt = fdd + "/" + fmm + "/" + fyyyy;
            //
            DateTime dTodt = DateTime.Parse(dtpToTotsale.Text);

            string strInc = "Select IDs,PurchaseDate,NetTotal from T_MakeInvoice Where Status<>'Cancel'";
            con = new OleDbConnection(dbCon());
            OleDbCommand cmd = new OleDbCommand(strInc, con);
            con.Open();
            OleDbDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                if (dr.IsDBNull(0) == false)
                {
                    string billNo = dr.GetValue(0).ToString();
                    string sDt = dr.GetValue(1).ToString();

                    DateTime dDt = Convert.ToDateTime(sDt);
                    //  string delD = chdate.ToShortDateString();
                    if (dFrdt <= dDt && dTodt >= dDt)
                    {
                        string str1 = "Select * from T_MakeInvoice Where Status<>'Cancel' and ID=" + billNo;
                        OleDbDataAdapter ada = new OleDbDataAdapter(str1, con);
                        ada.Fill(ds, "T_MakeInvoice");
                        sTot = dr.GetValue(2).ToString();
                        if (sTot != "")
                        {
                            totSale += Convert.ToDouble(sTot);
                        }
                        count += 1;
                    }
                }
                else
                {
                    MessageBox.Show("No Transaction", "No Transaction", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
            }
            dr.Close();
            // Update Total Customer Bill
            string TotBill = totSale.ToString("N2");
            string sRepTot = "Update T_ReportTotal Set CustDaybookTotal='" + TotBill + "' Where ID=1";
            OleDbCommand cmdRepTot = new OleDbCommand(sRepTot, con);
            cmdRepTot.ExecuteNonQuery();
            //
            string strTot = "Select CustDaybookTotal from T_ReportTotal Where ID=1";
            OleDbDataAdapter adaTot = new OleDbDataAdapter(strTot, con);
            adaTot.Fill(ds, "T_ReportTotal");
            //
            con.Close();
            lblNetAmt.Text = totSale.ToString("N2");
            if (count == 0)
            {
                ds.Clear();
                string str1 = "Select * from T_MakeInvoice Where Status<>'Cancel' and PurchaseDate=" + sFrdt;
                OleDbDataAdapter ada = new OleDbDataAdapter(str1, con);
                ada.Fill(ds, "T_MakeInvoice");
            }
            cr1.Refresh();
            cr1.SetDataSource(ds);
            progressBar1.SendToBack();
            progressBar1.Visible = false;
            crystalReportViewer1.Visible = true;
            crystalReportViewer1.ReportSource = cr1;
            Cursor.Current = Cursors.Default;
            crystalReportViewer1.Cursor = Cursors.Default;
            timer1.Enabled = true;
        }
        private void btnTotRsShow_Click(object sender, EventArgs e)
        {
            FromToDateChange();
        }
        private void dtpFrTotsale_ValueChanged(object sender, EventArgs e)
        {
            FromToDateChange();
        }

        private void dtpToTotsale_ValueChanged(object sender, EventArgs e)
        {
            FromToDateChange();
        }
        private void frmDayBook_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }
        public long sec = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (sec != -1)
            {
                lblNetAmt.Visible = !lblNetAmt.Visible;
                sec += 1;
                if (sec == 30)
                {
                    timer1.Enabled = false;
                    lblNetAmt.Visible = true;
                    sec = 0;
                }
            }
        }

how to create crystalreport in C#.net


 Cursor.Current = Cursors.WaitCursor;
            crystalReportViewer1.Cursor = Cursors.Default;
         
            crystalReportViewer1.Visible = true;
            DataSet ds = new DataSet();
            string str = "Select * from T_LoginMain";
            Con = new OleDbConnection(dbCon());
            OleDbDataAdapter ada = new OleDbDataAdapter(str, Con);
            Con.Open();
            ada.Fill(ds, "T_LoginMain");
            Con.Close();
            rptUsers cr1 = new rptUsers();
            cr1.Refresh();
            cr1.SetDataSource(ds);
            crystalReportViewer1.ReportSource = cr1;
            Cursor.Current = Cursors.Default;
            crystalReportViewer1.Cursor = Cursors.Default;

Wednesday, 7 May 2014

hard disk password remove tool


* Download Ultimate Boot CD
http://ubcd.sourceforge.net/download.html


* Burn it into a Disc and boot it up.

(Use ISO burner. If using windows 7, right click the file and choose “Burn Disc Image”)

* On main menu, choose “HDD” > “Diagnostic” > “MHDD v4.6″

* You will see a list of harddisk, select a harddisk you want to unlock

* Type “unlock” and reply “1″ for master password

* Enter the master password.
(If it is wrong, ERR will turns red on the top of the screen, and You have 4 more tries before it powercycle the disk)

* If it is correct, type “DISPWD” and reply “1″
(There will be a warning if your disk is still locked)

* Retype the master password again and your disk is unlocked!
(ERR will turn red if the password wrong)

* Type exit and press “ctrl + alt+ del” to reboot your computer

Hints:
* step 3 (on “MHDD v4.6″ menu), type “help” to get a list of commands and its function
* master password not working, please go to reference site below and look for “maximum security” part.

————————-Help for Master password———————————

SEAGATE -> “Seagate” + 25 spaces

MAXTOR
series N40P -> “Maxtor INIT SECURITY TEST STEP ” + 1 or + 2 spaces
series N40P -> “Maxtor INIT SECURITY TEST STEP F”
series 541DX -> “Maxtor” + 24 spaces
series Athena (D541X model 2B) and diamondmax80 -> “Maxtor”

WESTERN DIGITAL -> “WDCWDCWDCWDCWDCWDCWDCWDCWDCWDCWD”

FUJITSU -> 32 spaces

SAMSUNG -> “tttttttttttttttttttttttttttttttt” (32 times t)

IBM
series DTTA -> “CED79IJUFNATIT” + 18 spaces
series DJNA -> “VON89IJUFSUNAJ” + 18 spaces
series DPTA -> “VON89IJUFSUNAJ” + 18 spaces
series DTLA -> “RAM00IJUFOTSELET” + 16 spaces
series DADA-26480 (6,4gb) -> “BEF89IJUF__AIDACA” + 15 spaces

HITACHI series DK23AA, DK23BA and DK23CA -> 32 spaces

TOSHIBA -> 32 spaces

XBOX -> “XBOXSCENE” or “TEAMASSEMBLY”

Tuesday, 4 March 2014

SQL Server Data base path connections

 SqlConnection con = new SqlConnection("server=.\\sqlExpress;database=database;trusted_connection=true");