Search This Blog

Thursday, August 19, 2010

Crystal Report

public void FillCrystalReports(string strStoredProc, string CRPPath, CrystalReportViewer CRPViewer)
{
CRPPath=System.Web.HttpContext.Current.Server.MapPath(CRPPath);

try
{
SqlDataAdr = new SqlDataAdapter(strStoredProc, SqlConn);
SqlDataAdr.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlDataAdr.SelectCommand.CommandTimeout = 0;

ds = new DataSet();
ds.Locale = CultureInfo.InvariantCulture;


SqlDataAdr.Fill(ds);
ReportDocument Rep = new ReportDocument();
//Rep.SetDatabaseLogon("sa", "sa", ".", "SchoolDB");
Rep.Load(CRPPath);
Rep.SetDataSource(ds.Tables[0]);
CRPViewer.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
CRPViewer.ReportSource = Rep;
if (ds.Tables[0].Rows.Count == 0)
{
CRPViewer.Visible = false;
msgboxcs.MessageBox.Show("No Records Available");
}

}
catch (Exception ex)
{
msgboxcs.MessageBox.Show(ex.Message);
}
}
}





Print Crystal Reports 

using System;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ReportDocument cryRpt = new ReportDocument();
            cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt");

            TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
            TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
            ConnectionInfo crConnectionInfo = new ConnectionInfo();
            Tables CrTables;

            crConnectionInfo.ServerName = "YOUR SERVERNAME";
            crConnectionInfo.DatabaseName = "DATABASE NAME";
            crConnectionInfo.UserID = "USERID";
            crConnectionInfo.Password = "PASSWORD";

            CrTables = cryRpt.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }

            cryRpt.Refresh();
            cryRpt.PrintToPrinter(2, true, 1, 2);

        }
   }
}
C# Crystal Report Print 
crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);private void button2_Click(object sender, System.EventArgs e)
{
    //Open the PrintDialog
    this.printDialog1.Document = this.printDocument1;
    DialogResult dr = this.printDialog1.ShowDialog();
    if(dr == DialogResult.OK)
    {
        //Get the Copy times
        int nCopy = this.printDocument1.PrinterSettings.Copies;
        //Get the number of Start Page
        int sPage = this.printDocument1.PrinterSettings.FromPage;
        //Get the number of End Page
        int ePage = this.printDocument1.PrinterSettings.ToPage;
        //Get the printer name
        string PrinterName = this.printDocument1.PrinterSettings.PrinterName;

        crReportDocument = new ReportDocument();
        //Create an instance of a report
        crReportDocument = new Chart();
        try
        {
            //Set the printer name to print the report to. By default the sample
            //report does not have a defult printer specified. This will tell the
            //engine to use the specified printer to print the report. Print out 
            //a test page (from Printer properties) to get the correct value.

            crReportDocument.PrintOptions.PrinterName = PrinterName;


            //Start the printing process. Provide details of the print job
            //using the arguments.
            crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);

            //Let the user know that the print job is completed
            MessageBox.Show("Report finished printing!");
        }
        catch(Exception err)
        {
            MessageBox.Show(err.ToString());
        }
    }
}
Crystal Report Show to Date 
DS1 dts = new DS1();
            SqlConnection con = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True");

            try
            {
                DateTime dt = new DateTime();
                dt = Convert.ToDateTime(dateTimePicker1.Value.ToShortDateString());
                // SqlCommand cmd = new SqlCommand("SELECT * From JKL where Date='1/1/1900 12:00:00 AM' ", con);
                SqlCommand cmd = new SqlCommand("SELECT * From crtstaff where Date='" + dt + "'", con);

                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(dts.Tables["crtstaff"]);
                //  DataTable dt = new DataTable("JKL");
                // sda.Fill(dt);
                StaffDetails  cr = new StaffDetails();

                cr.SetDataSource(dts);
                crystalReportViewer1.ReportSource = cr;

                // cr.SetDataSource(dt);

            }
            catch (Exception ex)
            { }
        }

Wednesday, August 18, 2010

C#Program

Login Master
 public partial class Login___Master : Form
    {
        Dbclass db = new Dbclass();
        string common;
        public Login___Master()
        {
            InitializeComponent();
        }



        private void btnlogin_in_Click(object sender, EventArgs e)
        {
            DataTable dt2 = new DataTable();
            MDI objmdi = new MDI();

            if (cmblogin_type.Text == "")
            {
                MessageBox.Show("Error 9001303991 : FillUp the Login Type", "Blank..........", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }
            if (btnlogin_in.Text  == "Login")
            {

                //try
                {
                    string str = "login,'" + cmblogin_type.Text + "','" + cmbuser_name.Text + "','" + txtpassword.Text + "'";
                    dt2=db.FindFun(str);
                    if (dt2.Rows.Count > 0)
                    {
                        objmdi.Show();
                    }
                    else
                    {
                        MessageBox.Show("invalid user", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                   
                    }


                  
               }
          }
        }
   

        private void btnlogin_out_Click(object sender, EventArgs e)
        {
            MDI md = new MDI();
            md.Close();
        }

        private void Login___Master_Load(object sender, EventArgs e)
        {
            Dbclass obj = new Dbclass();
       
          // grpfind.Visible = true;
              string str = "Select * from user_master";

              obj.Fillcombo(cmblogin_type  , "user_type", "unq_id", str);
              obj.Fillcombo(cmbuser_name , "user_name", "unq_id", str);
        }


    }
}
----------------------------------------------------------------------
Message Show
 private void Form2_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!bClosing)
            {

                bClosing = true;

                if (MessageBox.Show("Are sure You want to exit?", "Exit?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
                else
                {
                    e.Cancel = false;
                }
            }
            else
            {
                bClosing = false;

            }
        }

        private void Form2_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void searchAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Search srch = new Search();
            srch.Show();
        }

        private void searchReportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchStatus srchst = new SearchStatus();
            srchst.Show();
        }
    }
}

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

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Bar_nd_Hotel
{
    public partial class crtVeg : Form
    {
        public crtVeg()
        {
            InitializeComponent();
        }
        AutoCompleteStringCollection codeCollection = new AutoCompleteStringCollection();
        List<string> arraylistitm = new List<string>();
        List<string> arraylistqty = new List<string>();



        private void crtVeg_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'bar_dbDataSet3.category' table. You can move, or remove it, as needed.
            this.categoryTableAdapter.Fill(this.bar_dbDataSet3.category);
            // TODO: This line of code loads data into the 'bar_dbDataSet1.veg_category' table. You can move, or remove it, as needed.
            //this.veg_categoryTableAdapter.Fill(this.bar_dbDataSet1.veg_category);


            string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
            SqlConnection con = new SqlConnection(constring);
            string cmdstring = "select crt_categ from category where main_cat = 'Veg. Items'";
            SqlCommand cmd = new SqlCommand(cmdstring, con);
            con.Open();
            SqlDataReader dr;
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                vegcatcmb.Items.Add(dr["crt_categ"].ToString());
            }



            string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
            SqlConnection con1 = new SqlConnection(constring1);
            string cmdstring1 = "select distinct itm_code from crt_veg order by itm_code";
            SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
            con1.Open();
            SqlDataReader dr1;
            dr1 = cmd1.ExecuteReader();
            if (dr1.HasRows == true)
            {
                while (dr1.Read())
                {
                    codeCollection.Add(dr1["itm_code"].ToString());
                }
            }
            dr1.Close();

            vegcode.AutoCompleteMode = AutoCompleteMode.Suggest;
            vegcode.AutoCompleteSource = AutoCompleteSource.CustomSource;
            vegcode.AutoCompleteCustomSource = codeCollection;
        }

        private void button1_Click(object sender, EventArgs e)
        {

            arraylistitm.Add(itm1.Text);
            arraylistitm.Add(itm2.Text);
            arraylistitm.Add(itm3.Text);
            arraylistitm.Add(itm4.Text);
            arraylistitm.Add(itm5.Text);
            arraylistitm.Add(itm6.Text);
            arraylistitm.Add(itm7.Text);
            arraylistitm.Add(itm8.Text);
            arraylistitm.Add(itm9.Text);
            arraylistitm.Add(itm10.Text);

            arraylistqty.Add(qty1.Text);
            arraylistqty.Add(qty2.Text);
            arraylistqty.Add(qty3.Text);
            arraylistqty.Add(qty4.Text);
            arraylistqty.Add(qty5.Text);
            arraylistqty.Add(qty6.Text);
            arraylistqty.Add(qty7.Text);
            arraylistqty.Add(qty8.Text);
            arraylistqty.Add(qty9.Text);
            arraylistqty.Add(qty10.Text);

            int n = 0;
            for (int j = 0; j < 10; j++)
            {
                if (arraylistitm[j].Length > 1)
                {
                    n++;
                }

            }


            for (int i = 0; i < n; i++)
            {

                if (i == 0)
                {
                    string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm1.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {
                       
                    }

                    else
                    {

                    string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con1 = new SqlConnection(constring1);
                    string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm1.Text + "', '" +Convert.ToDateTime( DateTime.Now.ToShortDateString()) + "') ";
                    //string cmdstring3 = "insert into daily_itm_invntry (cnt_name,date) values( '" + itm1.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "' ) ";
                    SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                    //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                    con1.Open();
                    cmd1.ExecuteNonQuery();
                    //cmd3.ExecuteNonQuery();
                    con1.Close();
                    }

                   
                }
                if (i == 1)
                {
                     string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm2.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm2.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "' ) ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name,date) values( '" + itm2.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }
                }
                if (i == 2)
                {
                     string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm3.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm3.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm3.Text + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }

                }
                if (i == 3)
                {
                      string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm4.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm4.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm4.Text + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }
                }
                if (i == 4)
                {
                      string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm5.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm5.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm5.Text + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }
                }
                if (i == 5)
                {
                      string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm6.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm6.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm6.Text + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }
                }
                if (i == 6)
                {
                      string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm7.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm7.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm7.Text + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }
                }
                if (i == 7)
                {
                      string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm8.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm8.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm8.Text + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }
                }
                if (i == 8)
                {
                      string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm9.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm9.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm9.Text + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }
                }
                if (i == 9)
                {
                      string constring2 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                    SqlConnection con2 = new SqlConnection(constring2);
                    string cmdstring2 = "select cnt_name from  itm_invntry where cnt_name =  '" + itm10.Text + "' ";
                    SqlCommand cmd2 = new SqlCommand(cmdstring2, con2);
                    con2.Open();
                    SqlDataReader dr2;  
                    dr2=cmd2.ExecuteReader();

                    if (dr2.Read())
                    {

                    }

                    else
                    {
                        string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
                        SqlConnection con1 = new SqlConnection(constring1);
                        string cmdstring1 = "insert into itm_invntry (cnt_name,date) values( '" + itm10.Text + "','" + Convert.ToDateTime(DateTime.Now.ToShortDateString()) + "') ";
                        //string cmdstring3 = "insert into daily_itm_invntry (cnt_name) values( '" + itm10.Text + "') ";
                        SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
                        //SqlCommand cmd3 = new SqlCommand(cmdstring3, con1);
                        con1.Open();
                        cmd1.ExecuteNonQuery();
                        //cmd3.ExecuteNonQuery();
                        con1.Close();
                    }
                }
            }
          



            string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
            SqlConnection con = new SqlConnection(constring);
            string cmdstring = "insert into crt_veg (itm_categ,itm_name,itm_code,itm_amt,itm1,qty1,itm2,qty2,itm3,qty3,itm4,qty4,itm5,qty5,itm6,qty6,itm7,qty7,itm8,qty8,itm9,qty9,itm10,qty10) values( '" + vegcatcmb.Text + "','" + vegname.Text + "', '" + Convert.ToInt32(vegcode.Text) + "', '" + vegamt.Text + "', '" + itm1.Text + "', '" + qty1.Text + "','" + itm2.Text + "', '" + qty2.Text + "','" + itm3.Text + "', '" + qty3.Text + "','" + itm4.Text + "', '" + qty4.Text + "','" + itm5.Text + "', '" + qty5.Text + "','" + itm6.Text + "', '" + qty6.Text + "','" + itm7.Text + "', '" + qty7.Text + "','" + itm8.Text + "', '" + qty8.Text + "','" + itm9.Text + "', '" + qty9.Text + "','" + itm10.Text + "', '" + qty10.Text + "') ";
            SqlCommand cmd = new SqlCommand(cmdstring, con);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();

            //for (int i = 0; i < n; i++)
            //{
              
            //        string cmdstring1 = "insert into VegCntItems (itm_code,itm_name,itm_cnt_name,itm_cnt_qty,itm_amt) values( '" + vegcode.Text + "','" + vegname.Text + "' , '" +  arraylistitm[i].ToString() + "', '" + arraylistqty[i].ToString() + "', '" + vegamt.Text + "') ";
            //        SqlCommand cmd1 = new SqlCommand(cmdstring1, con);
            //        con.Open();
            //        cmd1.ExecuteNonQuery();
            //        con.Close();
              
            //}

            MessageBox.Show("New Veg  Items has Been Added Successfully ");
            con.Close();
            //vegcatcmb.Text = "";
            //vegname.Text = "";
            //vegcode.Text = "";
            //vegamt.Text = "";
          
            con.Close();
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
            SqlConnection con = new SqlConnection(constring);
            string cmdstring = "update crt_veg set itm_name =  '" + vegname.Text + "',itm_amt = '" + vegamt.Text + "', itm1 = '" + itm1.Text + "',qty1 = '" + qty1.Text + "', itm2 = '" + itm2.Text + "',qty2 = '" + qty2.Text + "', itm3 = '" + itm3.Text + "',qty3 = '" + qty3.Text + "', itm4 = '" + itm4.Text + "',qty4 = '" + qty4.Text + "', itm5 = '" + itm5.Text + "',qty5 = '" + qty5.Text + "', itm6 = '" + itm6.Text + "',qty6 = '" + qty6.Text + "', itm7 = '" + itm7.Text + "',qty7 = '" + qty7.Text + "', itm8 = '" + itm8.Text + "',qty8 = '" + qty8.Text + "', itm9 = '" + itm9.Text + "',qty9 = '" + qty9.Text + "' , itm10 = '" + itm10.Text + "',qty10 = '" + qty10.Text + "' where itm_categ = '" + vegcatcmb.Text + "'  and itm_code = '" + vegcode.Text + "'  ";
            SqlCommand cmd = new SqlCommand(cmdstring, con);
            con.Open();
            cmd.ExecuteNonQuery();
            MessageBox.Show("Item details has been Updated Successfully  ");
            con.Close();
            //vegcatcmb.Text = "";
            //vegname.Text = "";
            //vegcode.Text = "";
            //vegamt.Text = "";

            con.Close();
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void qty6_TextChanged(object sender, EventArgs e)
        {

        }

        private void vegcode_TextChanged(object sender, EventArgs e)
        {
            //int n = 0;
            //string constring = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
            //SqlConnection con = new SqlConnection(constring);
            //string cmdstring = "select itm_code from VegCntItems where itm_code = '" + vegcode.Text + "'";
            //SqlCommand cmd = new SqlCommand(cmdstring, con);
            //con.Open();
            //SqlDataReader dr;
            //dr = cmd.ExecuteReader();
            //while (dr.Read())
            //{
            //    n++;
            //}






            string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
            SqlConnection con1 = new SqlConnection(constring1);
            string cmdstring1 = "select * from crt_veg where itm_code = '" + vegcode.Text + "'";
            SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
            con1.Open();
            SqlDataReader dr1;
            dr1 = cmd1.ExecuteReader();

            if (dr1.Read())
            {
                vegname.Text = dr1["itm_name"].ToString();
                vegamt.Text = dr1["itm_amt"].ToString();
                vegcatcmb.Text = dr1["itm_categ"].ToString();
                itm1.Text = dr1["itm1"].ToString();
                qty1.Text = dr1["qty1"].ToString();
                itm2.Text = dr1["itm2"].ToString();
                qty2.Text = dr1["qty2"].ToString();
                itm3.Text = dr1["itm3"].ToString();
                qty3.Text = dr1["qty3"].ToString();
                itm4.Text = dr1["itm4"].ToString();
                qty4.Text = dr1["qty4"].ToString();
                itm5.Text = dr1["itm5"].ToString();
                qty5.Text = dr1["qty5"].ToString();
                itm6.Text = dr1["itm6"].ToString();
                qty6.Text = dr1["qty6"].ToString();
                itm7.Text = dr1["itm7"].ToString();
                qty7.Text = dr1["qty7"].ToString();
                itm8.Text = dr1["itm8"].ToString();
                qty8.Text = dr1["qty8"].ToString();
                itm9.Text = dr1["itm9"].ToString();
                qty9.Text = dr1["qty9"].ToString();
                itm10.Text = dr1["itm10"].ToString();
                qty10.Text = dr1["qty10"].ToString();

            }
            else
            {
                vegname.Text = "";
                vegamt.Text = "";
                itm1.Text = "";
                qty1.Text = "";
                itm2.Text = "";
                qty2.Text = "";
                itm3.Text = "";
                qty3.Text = "";
                itm4.Text = "";
                qty4.Text = "";
                itm5.Text = "";
                qty5.Text = "";
                itm6.Text = "";
                qty6.Text = "";
                itm7.Text = "";
                qty7.Text = "";
                itm8.Text = "";
                qty8.Text = "";
                itm9.Text = "";
                qty9.Text = "";
                itm10.Text = "";
                qty10.Text = "";
            }
          
           
        }

        private void vegcatcmb_SelectedIndexChanged(object sender, EventArgs e)
        {
            string constring1 = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=bar_db;Integrated Security=True";
            SqlConnection con1 = new SqlConnection(constring1);
            string cmdstring1 = "select  itm_code from crt_veg where itm_categ = '" + vegcatcmb.Text + "' ";
            SqlCommand cmd1 = new SqlCommand(cmdstring1, con1);
            con1.Open();
            SqlDataReader dr1;
            dr1 = cmd1.ExecuteReader();
            if (dr1.HasRows == true)
            {
                while (dr1.Read())
                {
                    codeCollection.Add(dr1["itm_code"].ToString());
                }
            }
            else
            {
                codeCollection.Clear();
            }
            dr1.Close();

            vegcode.AutoCompleteMode = AutoCompleteMode.Suggest;
            vegcode.AutoCompleteSource = AutoCompleteSource.CustomSource;
            vegcode.AutoCompleteCustomSource = codeCollection;
        }
    }
}

Tuesday, August 17, 2010

Software Developer



    1.  I Am Software Developer At Jaipur
    2.  Software Developer Interview Questions
    3. Personality Fit, Warm up and General Background

      1. Tell us a little bit about yourself.
      2. Why are you leaving your current job?
      3. What would you like to do?
      4. What do you like about your current/former job? What don't you like?
      5. How would you rate your current/former management?
      6. What motivates you?
      7. Would you like to be the team leader or team member?
      8. Tell me about a conflict at a previous job and how you resolved it.
      9. (Summary personality item: Think to yourself, "Would I want to spend four hours driving in a car with this person I am interviewing?")
    4. Software Engineering Skills

      1. What is Object Oriented Design? What are the benefits and drawbacks?
      2. What is the Agile software philosophy?
      3. What is the Lean software philosophy?
      4. Have you looked at "Domain Driven Design"?
      5. What are the benefits of Dependency Injection?
      6. What books have you read on software engineering that you thought were good?
      7. What are the really important aspects of software development?
      8. Tell me about your philosophy of database design. Database tools?
      9. What are important aspects of GUI design?
      10. What Object Relational Mapping tools have you used?
      11. Tell me about the Model-View-Controller pattern and why it's important?
      12. What is Test Driven Development and Design? Why is it important?
      13. Describe some of the software patterns you have used?
      14. How do you design scalable applications?
      15. What is continuous integration?
      16. What is the REST architecture pattern?
      17. How would you design a solution to the following problem....
    5. Specific Technical Requirements

      1. General

        1. What software have you used for bug tracking and version control?
        2. What do you use for unit testing? GUI testing?
        3. Describe an interesting class you have designed.
        4. Have you been doing code reviews? What was the format?
        5. When and how do you optimize code?
        6. Describe your favorite build environment.
      2. Technical Questions for Web Developers

        1. What is the difference between GET and POST in web forms? How do you decide which to use?
        2. Tell me about HTTP?
        3. What is Service Oriented Architecture? Advantages and Disadvantages?
        4. What JavaScript libraries have you used?
        5. What is the advantage of using CSS? What are some of the irritating limitations of CSS?
    6. Passion for Software Development

      1. What are some influential software books you've read lately?
      2. What are your favorite technical web sites and blogs?
      3. Are you doing any interesting personal web projects?
      4. What do you like about software?
    7. A History Of Getting Jobs Done

      1. Tell me about your last project.
      2. Tell me about your part in the release of some important software.
      Even if you are not going to hire the person, you should be kind and encouraging. The universe is a vast unpredictable place. You may meet them at a professional society event. You may be looking for a job one day and interviewing with this person trying to get a job at their company. Stranger things have happened.
  1. Questions to ask prospective employers

    1. What is your software process?
    2. Tell me about your version control.
    3. What is your build process?
    4. Do you do continuous integration?
    5. Tell me about your bug tracking system.
    6. How is unit testing done? How is system testing done?
    7. Tell me about your Quality Assurance.
    8. How many hours per week do people usually work?
    9. What motivates your employees?
    10. Why is there an opening?
    11. What are your distinct advantages in the marketplace?
    12. How much training per year do you offer?
    13. Do you have a Wiki to share developer knowledge?
  2. Questions to ask possible future coworkers at a prospective employer

    1. How many training courses did you go to last year?
    2. How many hours per week do people usually work? How many hours do you work?
    3. What is the best thing you like about about working here?
    4. What is the worst thing about about working here?
    5. Why did the last person leave?
  3. Salary Research Sites

    1. www.indeed.com/salary
    2. www.payscale.com
    3. salary.com 


    Software Developer Requirements

    Hiring smart software developers is not easy. If you're not careful you might end up hiring a bunch of moronic mandrills, like I did last year. And you don't want that. Trust me. Stand-up meetings are very hard to do in a tree.
    The key is to ask challenging questions that enable you to distinguish the smart software developers from the moronic mandrills. And to help you with that, I decided to publish my private list of 100 interview questions for software developers.
    This list covers most of the knowledge areas as defined by the Software Engineering Body of Knowledge. Of course, if you're just looking for brilliant programmers, you may want to limit the topics to Construction, Algorithms, Data Structures and Testing. And if you're looking for architects, you can just consider the questions under the headings Requirements, Functional Design and Technical Design.
    But whatever you do, keep this in mind:
    For most of the questions in this list there are no right and wrong answers
    !
    My questions are simply starting points for interesting discussions. For example: there is a question about reasons to use static methods vs. singletons. If this triggers your candidate to start a tirade againt both static methods and singletons, there's a good chance you're dealing with a smart software developer! But if the candidate can produce nothing more than a blank stare and this sound, then he might very well be a moronic mandrill. Likewise, there are many correct ways to find out whether a number is a power of 2. But if the candidate suggests using the mod operator, well... you know what I mean. (And if you don't, no problem. Fancy a banana?)
    Requirements
  4. Can you name a number of non-functional (or quality) requirements?
  5. What is your advice when a customer wants high performance, high usability and high security?
  6. Can you name a number of different techniques for specifying requirements? What works best in which case?
  7. What is requirements tracing? What is backward tracing vs. forward tracing?
  8. Which tools do you like to use for keeping track of requirements?
  9. How do you treat changing requirements? Are they good or bad? Why?
  10. How do you search and find requirements? What are possible sources?
  11. How do you prioritize requirements? Do you know different techniques?
  12. Can you name the responsibilities of the user, the customer and the developer in the requirements process?
  13. What do you do with requirements that are incomplete or incomprehensible?
Functional Design
  1. What are metaphors used for in functional design? Can you name some successful examples?
  2. How can you reduce the user's perception of waiting when some functions take a lot of time?
  3. Which controls would you use when a user must select multiple items from a big list, in a minimal amount of space?
  4. Can you name different measures to guarantee correctness of data entry?
  5. Can you name different techniques for prototyping an application?
  6. Can you name examples of how an application can anticipate user behavior?
  7. Can you name different ways of designing access to a large and complex list of features?
  8. How would you design editing twenty fields for a list of 10 items? And editing 3 fields for a list of 1000 items?
  9. What is the problem of using different colors when highlighting pieces of a text?
  10. Can you name some limitations of a web environment vs. a Windows environment?
Technical Design
  1. What do low coupling and high cohesion mean? What does the principle of encapsulation mean?
  2. How do you manage conflicts in a web application when different people are editing the same data?
  3. Do you know about design patterns? Which design patterns have you used, and in what situations?
  4. Do you know what a stateless business layer is? Where do long-running transactions fit into that picture?
  5. What kinds of diagrams have you used in designing parts of an architecture, or a technical design?
  6. Can you name the different tiers and responsibilities in an N-tier architecture?
  7. Can you name different measures to guarantee correctness and robustness of data in an architecture?
  8. Can you name any differences between object-oriented design and component-based design?
  9. How would you model user authorization, user profiles and permissions in a database?
  10. How would you model the animal kingdom (with species and their behavior) as a class system?
Construction
  1. How do you make sure that your code can handle different kinds of error situations?
  2. Can you explain what Test-Driven Development is? Can you name some principles of Extreme Programming?
  3. What do you care about most when reviewing somebody else's code?
  4. When do you use an abstract class and when do you use an interface?
  5. Apart from the IDE, which other favorite tools do you use that you think are essential to you?
  6. How do you make sure that your code is both safe and fast?
  7. When do you use polymorphism and when do you use delegates?
  8. When would you use a class with static members and when would you use a Singleton class?
  9. Can you name examples of anticipating changing requirements in your code?
  10. Can you describe the process you use for writing a piece of code, from requirements to delivery?
Algorithms
  1. How do you find out if a number is a power of 2? And how do you know if it is an odd number?
  2. How do you find the middle item in a linked list?
  3. How would you change the format of all the phone numbers in 10,000 static html web pages?
  4. Can you name an example of a recursive solution that you created?
  5. Which is faster: finding an item in a hashtable or in a sorted list?
  6. What is the last thing you learned about algorithms from a book, magazine or web site?
  7. How would you write a function to reverse a string? And can you do that without a temporary string?
  8. What type of language do you prefer for writing complex algorithms?
  9. In an array with integers between 1 and 1,000,000 one value is in the array twice. How do you determine which one?
  10. Do you know about the Traveling Salesman Problem?
Data Structures
  1. How would you implement the structure of the London underground in a computer's memory?
  2. How would you store the value of a color in a database, as efficiently as possible?
  3. What is the difference between a queue and a stack?
  4. What is the difference between storing data on the heap vs. on the stack?
  5. How would you store a vector in N dimensions in a datatable?
  6. What type of language do you prefer for writing complex data structures?
  7. What is the number 21 in binary format? And in hex?
  8. What is the last thing you learned about data structures from a book, magazine or web site?
  9. How would you store the results of a soccer/football competition (with teams and scores) in an XML document?
  10. Can you name some different text file formats for storing unicode characters?
Testing
  1. Do you know what a regression test is? How do you verify that new changes have not broken existing features?
  2. How can you implement unit testing when there are dependencies between a business layer and a data layer?
  3. Which tools are essential to you for testing the quality of your code?
  4. What types of problems have you encountered most often in your products after deployment?
  5. Do you know what code coverage is? What types of code coverage are there?
  6. Do you know the difference between functional testing and exploratory testing? How would you test a web site?
  7. What is the difference between a test suite, a test case and a test plan? How would you organize testing?
  8. What kind of tests would you include for a smoke test of an ecommerce web site?
  9. What can you do reduce the chance that a customer finds things that he doesn't like during acceptance testing?
  10. Can you tell me something that you have learned about testing and quality assurance in the last year?
Maintenance
  1. What kind of tools are important to you for monitoring a product during maintenance?
  2. What is important when updating a product that is in production and is being used?
  3. How do you find an error in a large file with code that you cannot step through?
  4. How can you make sure that changes in code will not affect any other parts of the product?
  5. How do you create technical documentation for your products?
  6. What measures have you taken to make your software products more easily maintainable?
  7. How can you debug a system in a production environment, while it is being used?
  8. Do you know what load balancing is? Can you name different types of load balancing?
  9. Can you name reasons why maintenance of software is the biggest/most expensive part of an application's life cycle?
  10. What is the difference between re-engineering and reverse engineering?
Configuration Management
  1. Do you know what a baseline is in configuration management? How do you freeze an important moment in a project?
  2. Which items do you normally place under version control?
  3. How can you make sure that team members know who changed what in a software project?
  4. Do you know the differences between tags and branches? When do you use which?
  5. How would you manage changes to technical documentation, like the architecture of a product?
  6. Which tools do you need to manage the state of all digital information in a project? Which tools do you like best?
  7. How do you deal with changes that a customer wants in a released product?
  8. Are there differences in managing versions and releases?
  9. What is the difference between managing changes in text files vs. managing changes in binary files?
  10. How would you treat simultaneous development of multiple RfC's or increments and maintenance issues?
Project Management
  1. How many of the three variables scope, time and cost can be fixed by the customer?
  2. Who should make estimates for the effort of a project? Who is allowed to set the deadline?
  3. Do you prefer minimization of the number of releases or minimization of the amount of work-in-progress?
  4. Which kind of diagrams do you use to track progress in a project?
  5. What is the difference between an iteration and an increment?
  6. Can you explain the practice of risk management? How should risks be managed?
  7. Do you prefer a work breakdown structure or a rolling wave planning?
  8. What do you need to be able to determine if a project is on time and within budget?
  9. Can you name some differences between DSDM, Prince2 and Scrum?
  10. How do you agree on scope and time with the customer, when the customer wants too much?