Tuesday, 23 April 2013

TextBox take only numeric in c# Code Behind

 private void vtbPhno_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (char.IsDigit(e.KeyChar) == false)
                    e.Handled = true;
                else
                    e.Handled = false;
            }
            catch (Exception)
            {
                e.Handled = false;
            }
        }

Update a table from another one



update dbo.ISSUE_BARCODES
set itm_code = t2.itm_code,im_code=t2.im_code,gross_wt=t2.obm_wght,net_wt=t2.obm_net_wt
from dbo.ISSUE_BARCODES t1 inner join temp_1 t2
on t1.barcode=t2.obm_brcd

Transanction for sql in store procedure

begin try
        begin transaction
    Update SubMenu_Master set Menu_Id=@Menu_Id,Sub_Menu_Name=@Sub_Menu_Name,
    Sub_Menu_Description=@Sub_Menu_Description,Sub_Menu_Shortcut=@Sub_Menu_Shortcut
   where Sub_Menu_Id=@Sub_Menu_Id;

Update Menu_List_Details set Menu_Id=@Menu_Id where Sub_Menu_Id=@Sub_Menu_Id;

    SET @message='Update Successfully';
    commit transaction
    end try
    begin catch
        rollback transaction
    end catch

Monday, 22 April 2013

Table's Column Name Count

SELECT count(*)
FROM information_schema.columns
WHERE table_name = 'DailyTransactions'

Sunday, 21 April 2013

Highest Salary of any, in sql query


select distinct sal from salary s1 where n = (select count(distinct sal) from salary s2 where s1.sal <= s2.sal)
--n is the no. of integer of any highest salary.

Caountry Name fetching in c# code without Database


private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.DataSource = getcultureinfo();
        }
        private IList<string> getcultureinfo()
        {
            List<string> list = new List<string>();
            foreach (CultureInfo info in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
            {
                RegionInfo inforeg = new RegionInfo(info.LCID);
                if(!list.Contains(inforeg.EnglishName))
                {
                    list.Add(inforeg.EnglishName);
                    list.Sort();
                }
            }
            return list;
        }

Validation given to a project for some days

if ((System.DateTime.Today.Day >= 1 && System.DateTime.Today.Month == 12)||System.DateTime.Today.Year==2012)
                {
                    MessageBox.Show("Your Software already Collaspsed Please register your product");
                }
                 else
                {
                    if (System.DateTime.Today.Day >= 10 && System.DateTime.Today.Month == 12)//10 and 12 you can take it from xml file or other
                    {
                        MessageBox.Show("You Should Renew Your Software within 15 days Otherwise it will Collaspe","DJSplashSinglePoint",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    }
//this condition is given according to project requirement
                    blkPkt = null;
                    _modeType = FormModes.Add;
                    ResetControl(_modeType);
                    txtRefVrNo.Focus();
                }