Tuesday, 14 May 2013

radio button list ( load enum values)

 c# coding

private void FillVoucherList()
    {
        rbtnlVoucherType.DataSource = System.Enum.GetValues(typeof(VoucherTypes));
        rbtnlVoucherType.DataBind();
        rbtnlVoucherType.SelectedValue = VoucherTypes.Journal.ToString(); //it is the default selection of vouchertype as "Journal"                 
    }// rbtnlVoucherType is the radio button list

Asp .net coding

  <tr>
                        <td class="captionColumn">
                            Status
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <asp:RadioButtonList ID="rbtnlStatus" runat="server" RepeatDirection="Horizontal"
                                AutoPostBack="True">
                            </asp:RadioButtonList>
                        </td>
                    </tr>

Enum declaration

 public partial class Voucher
    {

        public VoucherTypes VoucherType
        {
            get { return (VoucherTypes)this.VoucherTypeId; }//id value in database field
            set { this.VoucherTypeId = (int)value; }
        }
    }
  
    public enum VoucherTypes
    {
        Journal = 0,
        Payment = 1,
        Receive = 2,
        Contra = 3,       
    }

Tuesday, 23 April 2013

email sending Codes in windows application .net


System.Net.Mail.MailMessage objMMsg = new System.Net.Mail.MailMessage();
                                objMMsg.To.Add("haimrutyunjaya@gmail.com");// "mrutyunjaya.das@sagacityinfotech.co.in";
                                objMMsg.From = new System.Net.Mail.MailAddress("mrutyunjaya.das@sagacityinfotech.co.in");

                                objMMsg.Subject = "Tester mail";
                                objMMsg.Body = "This is atest mail no need to replay";

                                System.Net.Mail.SmtpClient smtpMail = new System.Net.Mail.SmtpClient();
                                smtpMail.Host = "smtp.gmail.com";
                                smtpMail.Port = 587;
                                smtpMail.EnableSsl = true;
                                smtpMail.Credentials = new System.Net.NetworkCredential("mrutyunjaya.das@sagacityinfotech.co.in", "sagacity");
                                smtpMail.Send(objMMsg);                              

                                //MessageBox.Show("Successfull");
                                //Mail objmail = new Mail();
                                //objmail.sendMail("mrutyunjaya.das@sagacityinfotech.co.in", "Testing1111111", "Test mail");

Row Duplicate(How to avoid) in table

select bcm_brcd,count(bcm_brcd) as dup_count  from vw_JSP_STOCK_SUMRY_TAX_INV_SALE where itm_id=101
group by bcm_brcd having (count(bcm_brcd)>1)

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