Saturday, 29 December 2012

how to send mail thrount sql server

In order to send mail using Database Mail in SQL Server, there are 3 basic steps that need to be carried out:
  1. Create Profile and Account
  2. Configure Email
  3. Send Email

Step 1: Create Profile and Account

You need to create a profile and account using the Configure Database Mail Wizard which can be accessed from the Configure Database Mail context menu of the Database Mail node in Management Node.
This wizard is used to manage accounts, profiles, and Database Mail global settings which are shown below:











Step 2: Configure Email

After the Account and the Profile are created successfully, we need to configure the Database Mail. To configure it, we need to enable the Database Mail XPs parameter through the sp_configure stored procedure, as shown here:
sp_CONFIGURE 'show advanced', 1 GO RECONFIGURE GO sp_CONFIGURE _
 'Database Mail XPs', 1 GO RECONFIGURE GO 

Step 3: Send Email

After all configurations are done, we are now ready to send an email. To send mail, we need to execute a stored procedure sp_send_dbmail and provide the required parameters as shown below:
USE msdb GO EXEC sp_send_dbmail @profile_name='PinalProfile', _
@recipients='test@Example.com', @subject='Test message', _
@body='This is the body of the test message. _
Congrats Database Mail Received By you Successfully.' 

After all validations of the parameters entered are done, certain stored procedures are executed and the mail is queued by Service Broker. Read more at SQL SERVER - Introduction to Service Broker.
Database Mail keeps copies of outgoing e-mail messages and displays them in the sysmail_allitems, sysmail_sentitems, sysmail_unsentitems, sysmail_faileditems. The status of the mail sent can be seen in sysmail_mailitems table. When the mail is sent successfully, the sent_status field of the sysmail_mailitems table is set to 1 which can again be seen in sysmail_sentitems table. The mails that have failed will have the sent_status field value to 2 and those are unsent will have value 3. The log can be checked in sysmail_log table as shown below:
SELECT * FROM sysmail_mailitems GO SELECT * FROM sysmail_log GO 

Status can be verified using sysmail_sentitems table.

master page in c#.net

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 Swash.BusinessLayer;
using Swash.Frameworks;
using Swash.Objects;
using Barcodes.Properties;

namespace Barcodes
{
    public partial class frmHome : Form
    {
        #region Header

        private void btnCommon_Click(object sender, EventArgs e)
        {
            ImageChange("click", "top", "common_hover.png", btnCommon);
            pnlBody.Controls.Clear();
            ManagePanel();
            ToggleVisiblePanel();
            PanelCommon.Visible = true;
        }

        private void btnItem_Click(object sender, EventArgs e)
        {
            ImageChange("click", "top", "item_hover.png", btnItem);
            pnlBody.Controls.Clear();
            ManagePanel();
            ToggleVisiblePanel();
            PanelItem.Visible = true;
        }

        private void btnStock_Click(object sender, EventArgs e)
        {
            ImageChange("click", "top", "stock_hover.png", btnStock);
            pnlBody.Controls.Clear();
            ManagePanel();
            ToggleVisiblePanel();
            PanelStock.Visible = true;
        }

        private void btnKitting_Click(object sender, EventArgs e)
        {
            ImageChange("click", "top", "kitting_hover.png", btnKitting);
            pnlBody.Controls.Clear();
            ManagePanel();
            ToggleVisiblePanel();
            PanelKitting.Visible = true;
        }

        private void btnSetup_Click(object sender, EventArgs e)
        {
            ImageChange("click", "top", "setup_hover.png", btnSetup);
            pnlBody.Controls.Clear();
            ToggleVisiblePanel();
            PanelSetup.Visible = true;
            //frmSetup objPage = new frmSetup();
            //objPage.TopLevel = false;
            //objPage.Visible = true;
            //pnlBody.Controls.Clear();
            //pnlBody.Controls.Add(objPage);
        }

        private void btnTools_Click(object sender, EventArgs e)
        {
            ImageChange("click", "top", "tools_hover.png", btnTools);
            pnlBody.Controls.Clear();
            ManagePanel();
            ToggleVisiblePanel();
            PanelTools.Visible = true;
        }

        #endregion

        #region Common

        public void btnCategory_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "category_hover.png", btnCategory);
            frmCategories objPage = new frmCategories();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnBrand_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "brand_hover.png", btnBrand);
            frmBrand objPage = new frmBrand();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnColour_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "color_hover.png", btnColour);
            frmColor objPage = new frmColor();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnClarity_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "clarity_hover.png", btnClarity);
            frmClarity objPage = new frmClarity();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnDesign_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "design_hover.png", btnDesign);
            frmDesign objPage = new frmDesign();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnStone_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "stone_hover.png", btnStone);
            frmStone objPage = new frmStone();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnStoneCut_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "stone_cut_hover.png", btnStoneCut);
            frmStoneCut objPage = new frmStoneCut();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnGrade_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "grade_hover.png", btnGrade);
            frmGrade objPage = new frmGrade();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnPurity_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "purity_hover.png", btnPurity);
            frmPurity objPage = new frmPurity();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void btnItemMatrix_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "matrix_field_hover.png", btnItemMatrix);
            frmMatrixFields objPage = new frmMatrixFields();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnItemType_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "item_type_hover.png", BtnItemType);
            frmItemType objPage = new frmItemType();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnStore_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "store_hover.png", BtnStore);
            frmManageStore objPage = new frmManageStore();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        #endregion

        #region Item

        void Setup()
        {
            BtnBarcode.Location = BtnItemDetails.Location;
            BtnItemDetails.Location = BtnManageMatrix.Location;
            BtnManageMatrix.Visible = false;
            BtnManageItem.Visible = false;
        }

        private void BtnManageMatrix_Click(object sender, EventArgs e)
        {
            //ImageChange("click", "body", "manage_matrix_hover.png", BtnManageMatrix);
            //frmMatrixDisplay objPage = new frmMatrixDisplay();
            //objPage.TopLevel = false;
            //objPage.Visible = true;
            //pnlBody.Controls.Clear();
            //pnlBody.Controls.Add(objPage);
        }

        private void BtnManageItem_Click(object sender, EventArgs e)
        {
            //ImageChange("click", "body", "manage_item_hover.png", BtnManageItem);
            //frmMatrixDataEntry objPage = new frmMatrixDataEntry();
            //objPage.TopLevel = false;
            //objPage.Visible = true;
            //pnlBody.Controls.Clear();
            //pnlBody.Controls.Add(objPage);
        }

        private void BtnItemDetails_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "item_details_hover.png", BtnItemDetails);
            frmItems objPage = new frmItems();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnBarcode_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "barcode_hover.png", BtnBarcode);
            frmPrintBarcode objPage = new frmPrintBarcode();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        #endregion

        #region Stock

        private void BtnManageStock_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "manage_stock_hover.png", BtnManageStock);
            frmStock objPage = new frmStock();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnIssueToQC_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "issue_qc_hover.png", BtnIssueToQC);
            frmIssueToQualityControl objPage = new frmIssueToQualityControl();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnApproveQC_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "approve_qc_hover.png", BtnApproveQC);

        }

        private void BtnReceiveFromQC_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "rcv_qc_hover.png", BtnReceiveFromQC);
            frmReceivedFromQC objPage = new frmReceivedFromQC();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }
        private void BtnPurchaseOrder_Click(object sender, EventArgs e)
        {
            //ImageChange("click", "body", "purchase_order_hover.png", BtnPurchaseOrder);
            frmPurchaseOrder objPage = new frmPurchaseOrder();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        #endregion

        #region Kitting

        private void BtnKitSetup_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "kit_setup_hover.png", BtnKitSetup);
            frmKitSetUp objPage = new frmKitSetUp();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnApproveKit_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "approve_kit_hover.png", BtnApproveKit);
            frmKittingApproval objPage = new frmKittingApproval();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnIssueKit_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "issue_kit_hover.png", BtnIssueKit);
            frmIssueForPackingAndKitting1 objPage = new frmIssueForPackingAndKitting1();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnReceiveKit_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "receive_kit_hover.png", BtnReceiveKit);
            frmReceiveFromPackingAndKitting objPage = new frmReceiveFromPackingAndKitting();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        #endregion

        #region Setup

        private void BtnUser_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "approve_kit_hover.png", BtnApproveKit);
            frmUser objPage = new frmUser();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }
        private void BtnUserPrivillages_Click(object sender, EventArgs e)
        {
            //ImageChange("click", "body", "barcode_type_hover.png", BtnBarcodeType);
            frmDynamiMenu objPage = new frmDynamiMenu();
           // objPage.TopLevel = false;
            //objPage.Visible = true;
            //pnlBody.Controls.Clear();
            //pnlBody.Controls.Add(objPage);
            objPage.ShowDialog();
        }

        private void BtnBarcodeType_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "barcode_type_hover.png", BtnBarcodeType);
            frmBarcodeType objPage = new frmBarcodeType();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        #endregion

        #region Tools
        private void BtnBackup_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "backup_hover.png", BtnBackup);
            frmBackup objPage = new frmBackup();
            //frmPrintBarcode objPage = new frmPrintBarcode();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

        private void BtnRestore_Click(object sender, EventArgs e)
        {
            frmMenu objPage = new frmMenu();
            //frmPrintBarcode objPage = new frmPrintBarcode();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);

            //ImageChange("click", "body", "restore_hover.png", BtnRestore);
            //frmItems objPage = new frmItems();
            //objPage.TopLevel = false;
            //objPage.Visible = true;
            //pnlBody.Controls.Clear();
            //pnlBody.Controls.Add(objPage);
        }
        #endregion

        #region Other Event And Methods

        public frmHome()
        {
            InitializeComponent();
        }

        private void frmHome_Load(object sender, EventArgs e)
        {
            btnCommon_Click(sender, e); // Check it according to user previllage
            DateTime dt = DateTime.Now.Date;
            lblTime.Text = DateTime.Now.ToString("dd MMMM yyyy");
            //lblTime.Text = String.Format("{0:F}", dt);
            ManagePanel();
            Setup();

            if (frmLogin.username != null && frmLogin.username != "")
            {
                LblUserName.Visible = true;
                LblWelcome.Visible = true;
                LblUserName.Text = frmLogin.username;
            }
            BtnApproveQC.Visible = false;
        }

        private void btnTax_Click(object sender, EventArgs e)
        {
            //============Bank===========
            //ImageChange("click", "body", "tax_hover.png", btnTax);
            //frmBank objPage = new frmBank();
            //objPage.TopLevel = false;
            //objPage.Visible = true;
            //pnlBody.Controls.Clear();
            //pnlBody.Controls.Add(objPage);
            //============Bank===========
            ImageChange("click", "body", "tax_hover.png", btnTax);
            frmVendor objPage = new frmVendor();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }
        //Image Manipulation for Controls
        private void btnAll_MouseHover(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            //-----------Header--------------
            if (btn.Name == "btnSetup")
                ImageChange("hover", "top", "setup_hover.png", btn);
            if (btn.Name == "btnItem")
                ImageChange("hover", "top", "item_hover.png", btn);
            if (btn.Name == "btnStock")
                ImageChange("hover", "top", "stock_hover.png", btn);
            if (btn.Name == "btnKitting")
                ImageChange("hover", "top", "kitting_hover.png", btn);
            if (btn.Name == "btnCommon")
                ImageChange("hover", "top", "common_hover.png", btn);
            if (btn.Name == "btnTools")
                ImageChange("hover", "top", "tools_hover.png", btn);
            //-----------Common--------------
            if (btn.Name == "btnStone")
                ImageChange("hover", "body", "stone_hover.png", btn);
            if (btn.Name == "btnColour")
                ImageChange("color_hover", "body", "color_hover.png", btn);
            if (btn.Name == "btnClarity")
                ImageChange("hover", "body", "clarity_hover.png", btn);
            if (btn.Name == "btnStoneCut")
                ImageChange("hover", "body", "stone_cut_hover.png", btn);
            if (btn.Name == "btnDesign")
                ImageChange("hover", "body", "design_hover.png", btn);
            if (btn.Name == "btnBrand")
                ImageChange("brand_hover", "body", "brand_hover.png", btn);
            if (btn.Name == "btnGrade")
                ImageChange("hover", "body", "grade_hover.png", btn);
            if (btn.Name == "btnPurity")
                ImageChange("hover", "body", "purity_hover.png", btn);
            if (btn.Name == "btnItemMatrix")
                ImageChange("hover", "body", "matrix_field_hover.png", btn);
            if (btn.Name == "btnTax")
                ImageChange("hover", "body", "tax_hover.png", btn);
            if (btn.Name == "btnCategory")
                ImageChange("hover", "body", "category_hover.png", btn);

            if (btn.Name == "BtnItemType")
                ImageChange("hover", "body", "item_type_hover.png", btn);
            if (btn.Name == "BtnStore")
                ImageChange("hover", "body", "store_hover.png", btn);
            //-----------Item--------------
            if (btn.Name == "BtnManageMatrix")
                ImageChange("hover", "body", "manage_matrix_hover.png", btn);
            if (btn.Name == "BtnManageItem")
                ImageChange("hover", "body", "manage_item_hover.png", btn);
            if (btn.Name == "BtnItemDetails")
                ImageChange("hover", "body", "item_details_hover.png", btn);
            if (btn.Name == "BtnBarcode")
                ImageChange("hover", "body", "barcode_hover.png", btn);
            //-----------Stock--------------
            if (btn.Name == "BtnManageStock")
                ImageChange("hover", "body", "manage_stock_hover.png", btn);
            if (btn.Name == "BtnIssueToQC")
                ImageChange("hover", "body", "issue_qc_hover.png", btn);
            if (btn.Name == "BtnApproveQC")
                ImageChange("hover", "body", "approve_qc_hover.png", btn);
            if (btn.Name == "BtnReceiveFromQC")
                ImageChange("hover", "body", "rcv_qc_hover.png", btn);
            //if (btn.Name == "BtnPurchaseOrder")
            //    ImageChange("hover", "body", "purchase_order_hover.png", btn);

            //-----------Kitting--------------
            if (btn.Name == "BtnKitSetup")
                ImageChange("hover", "body", "kit_setup_hover.png", btn);
            if (btn.Name == "BtnApproveKit")
                ImageChange("hover", "body", "approve_kit_hover.png", btn);
            if (btn.Name == "BtnIssueKit")
                ImageChange("hover", "body", "issue_kit_hover.png", btn);
            if (btn.Name == "BtnReceiveKit")
                ImageChange("hover", "body", "receive_kit_hover.png", btn);

            //-----------Setup--------------
            if (btn.Name == "BtnUser")
                ImageChange("hover", "body", "user_hover.png", btn);
            if (btn.Name == "BtnUserPrivillages")
                ImageChange("hover", "body", "user_privileges_hover.png", btn);
            if (btn.Name == "BtnBarcodeType")
                ImageChange("hover", "body", "barcode_type_hover.png", btn);
            //-----------Tools--------------
            if (btn.Name == "BtnBackup")
                ImageChange("hover", "body", "backup_hover.png", btn);
            if (btn.Name == "BtnRestore")
                ImageChange("hover", "body", "restore_hover.png", btn);

        }
        private void btnAll_MouseLeave(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            //-----------Header--------------
            if (btn.Name == "btnSetup")
                ImageChange("hover", "top", "setup.png", btn);
            if (btn.Name == "btnItem")
                ImageChange("hover", "top", "item.png", btn);
            if (btn.Name == "btnStock")
                ImageChange("hover", "top", "stock.png", btn);
            if (btn.Name == "btnKitting")
                ImageChange("hover", "top", "kitting.png", btn);
            if (btn.Name == "btnCommon")
                ImageChange("hover", "top", "common.png", btn);
            if (btn.Name == "btnTools")
                ImageChange("hover", "top", "tools.png", btn);
            //-----------Common--------------
            if (btn.Name == "btnStone")
                ImageChange("hover", "body", "stone.png", btn);
            if (btn.Name == "btnColour")
                ImageChange("color", "body", "color.png", btn);
            if (btn.Name == "btnClarity")
                ImageChange("hover", "body", "clarity.png", btn);
            if (btn.Name == "btnStoneCut")
                ImageChange("hover", "body", "stone_cut.png", btn);
            if (btn.Name == "btnDesign")
                ImageChange("hover", "body", "design.png", btn);
            if (btn.Name == "btnBrand")
                ImageChange("brand", "body", "brand.png", btn);
            if (btn.Name == "btnGrade")
                ImageChange("hover", "body", "grade.png", btn);
            if (btn.Name == "btnPurity")
                ImageChange("hover", "body", "purity.png", btn);
            if (btn.Name == "btnItemMatrix")
                ImageChange("hover", "body", "matrix_field.png", btn);
            if (btn.Name == "btnTax")
                ImageChange("hover", "body", "tax.png", btn);
            if (btn.Name == "btnCategory")
                ImageChange("hover", "body", "category.png", btn);


            if (btn.Name == "BtnItemType")
                ImageChange("hover", "body", "item_type.png", btn);
            if (btn.Name == "BtnStore")
                ImageChange("hover", "body", "store.png", btn);


            //-----------Item--------------
            if (btn.Name == "BtnManageMatrix")
                ImageChange("hover", "body", "manage_matrix.png", btn);
            if (btn.Name == "BtnManageItem")
                ImageChange("hover", "body", "manage_item.png", btn);
            if (btn.Name == "BtnItemDetails")
                ImageChange("hover", "body", "item_details.png", btn);
            if (btn.Name == "BtnBarcode")
                ImageChange("hover", "body", "barcode.png", btn);
            //-----------Stock--------------
            if (btn.Name == "BtnManageStock")
                ImageChange("hover", "body", "manage_stock.png", btn);
            if (btn.Name == "BtnIssueToQC")
                ImageChange("hover", "body", "issue_qc.png", btn);
            if (btn.Name == "BtnApproveQC")
                ImageChange("hover", "body", "approve_qc.png", btn);
            if (btn.Name == "BtnReceiveFromQC")
                ImageChange("hover", "body", "rcv_qc.png", btn);
            //if (btn.Name == "BtnPurchaseOrder")
            //    ImageChange("hover", "body", "purchase_order.png", btn);

            //-----------Kitting--------------
            if (btn.Name == "BtnKitSetup")
                ImageChange("hover", "body", "kit_setup.png", btn);
            if (btn.Name == "BtnApproveKit")
                ImageChange("hover", "body", "approve_kit.png", btn);
            if (btn.Name == "BtnIssueKit")
                ImageChange("hover", "body", "issue_kit.png", btn);
            if (btn.Name == "BtnReceiveKit")
                ImageChange("hover", "body", "receive_kit.png", btn);

            //-----------Setup--------------
            if (btn.Name == "BtnUser")
                ImageChange("hover", "body", "user.png", btn);
            if (btn.Name == "BtnUserPrivillages")
                ImageChange("hover", "body", "user_privileges.png", btn);
            if (btn.Name == "BtnBarcodeType")
                ImageChange("hover", "body", "barcode_type.png", btn);
            //-----------Tools--------------
            if (btn.Name == "BtnBackup")
                ImageChange("hover", "body", "backup.png", btn);
            if (btn.Name == "BtnRestore")
                ImageChange("hover", "body", "restore.png", btn);
        }

        Button ButtonTop = null; string ImageTop = null;
        Button ButtonBody = null; string ImageBody = null;
        protected void ImageChange(string type, string level, string imagename, Button btn) //Type for hover, click ---- and level for top or body
        {
            if (type == "click")
            {
                Button btnPrev = null; string ImagePrev = null;
                if (level == "top") { btnPrev = ButtonTop; ImagePrev = ImageTop; ButtonTop = btn; ImageTop = imagename; }
                else { btnPrev = ButtonBody; ImagePrev = ImageBody; ButtonBody = btn; ImageBody = imagename; }

                if (btnPrev != null)
                {
                    ImagePrev = ImagePrev.Substring(0, ImagePrev.Length - ImagePrev.StartsWith("_").ToString().Length - 5) + ".png";
                    ImageChange("hover", level, ImagePrev, btnPrev);
                }
                ImageLoad(imagename, btn);
            }
            else
            {
                if (level == "top") { if (ButtonTop != btn)ImageLoad(imagename, btn); }
                else { if (ButtonBody != btn) ImageLoad(imagename, btn); }
            }
        }
        //void ImageLoad(string imagename, Button btn)
        //{
        //    string ImagePath = (System.Environment.CurrentDirectory);
        //    ImagePath = ImagePath.Substring(0, ImagePath.Length - ImagePath.StartsWith("bin").ToString().Length - 4);
        //    btn.BackgroundImage = Image.FromFile("" + ImagePath + "Resources/" + imagename);
        //}
        void ImageLoad(string imagename, Button btn)
        {
            btn.BackgroundImage = GetImage(imagename);
        }
        Bitmap GetImage(string imagename)
        {
            Bitmap btImage = null;
            switch (imagename)
            {
                case "common.png": btImage = Resources.common; break;
                case "common_hover.png": btImage = Resources.common_hover; break;
                case "item.png": btImage = Resources.item; break;
                case "item_hover.png": btImage = Resources.item_hover; break;
                case "stock.png": btImage = Resources.stock; break;
                case "stock_hover.png": btImage = Resources.stock_hover; break;
                case "kitting.png": btImage = Resources.kitting; break;
                case "kitting_hover.png": btImage = Resources.kitting_hover; break;
                case "setup.png": btImage = Resources.setup; break;
                case "setup_hover.png": btImage = Resources.setup_hover; break;
                case "tools.png": btImage = Resources.tools; break;
                case "tools_hover.png": btImage = Resources.tools_hover; break;
                case "category.png": btImage = Resources.category; break;
                case "category_hover.png": btImage = Resources.category_hover; break;
                case "brand.png": btImage = Resources.brand; break;
                case "brand_hover.png": btImage = Resources.brand_hover; break;
                case "color.png": btImage = Resources.color; break;
                case "color_hover.png": btImage = Resources.color_hover; break;
                case "clarity.png": btImage = Resources.clarity; break;
                case "clarity_hover.png": btImage = Resources.clarity_hover; break;
                case "design.png": btImage = Resources.design; break;
                case "design_hover.png": btImage = Resources.design_hover; break;

                case "stone.png": btImage = Resources.stone; break;
                case "stone_hover.png": btImage = Resources.stone_hover; break;
                case "stone_cut.png": btImage = Resources.stone_cut; break;
                case "stone_cut_hover.png": btImage = Resources.stone_cut_hover; break;
                case "grade.png": btImage = Resources.grade; break;
                case "grade_hover.png": btImage = Resources.grade_hover; break;
                case "purity.png": btImage = Resources.purity; break;
                case "purity_hover.png": btImage = Resources.purity_hover; break;

                case "item_type.png": btImage = Resources.item_type; break;
                case "item_type_hover.png": btImage = Resources.item_type_hover; break;
                case "store.png": btImage = Resources.store; break;
                case "store_hover.png": btImage = Resources.store_hover; break;
                case "matrix_field.png": btImage = Resources.matrix_field; break;
                case "matrix_field_hover.png": btImage = Resources.matrix_field_hover; break;


                //-----------Stock--------------
                case "manage_stock_hover.png": btImage = Resources.manage_stock_hover; break;
                case "issue_qc_hover.png": btImage = Resources.issue_qc_hover; break;
                case "approve_qc_hover.png": btImage = Resources.approve_qc_hover; break;
                case "rcv_qc_hover.png": btImage = Resources.rcv_qc_hover; break;
                case "manage_stock.png": btImage = Resources.manage_stock; break;
                case "issue_qc.png": btImage = Resources.issue_qc; break;
                case "approve_qc.png": btImage = Resources.approve_qc; break;
                case "rcv_qc.png": btImage = Resources.rcv_qc; break;


                //-----------Kitting--------------
                case "kit_setup_hover.png": btImage = Resources.kit_setup_hover; break;
                case "approve_kit_hover.png": btImage = Resources.approve_kit_hover; break;
                case "issue_kit_hover.png": btImage = Resources.issue_kit_hover; break;
                case "receive_kit_hover.png": btImage = Resources.receive_kit_hover; break;
                case "kit_setup.png": btImage = Resources.kit_setup; break;
                case "approve_kit.png": btImage = Resources.approve_kit; break;
                case "issue_kit.png": btImage = Resources.issue_kit; break;
                case "receive_kit.png": btImage = Resources.receive_kit; break;

                //-----------Setup--------------
                case "user_hover.png": btImage = Resources.user_hover; break;
                case "user_privileges_hover.png": btImage = Resources.user_privileges_hover; break;
                case "barcode_type_hover.png": btImage = Resources.barcode_type_hover; break;
                case "user.png": btImage = Resources.user; break;
                case "user_privileges.png": btImage = Resources.user_privileges; break;
                case "barcode_type.png": btImage = Resources.barcode_type; break;

                //-----------Tools--------------
                case "backup_hover.png": btImage = Resources.backup_hover; break;
                case "restore_hover.png": btImage = Resources.restore_hover; break;
                case "backup.png": btImage = Resources.backup; break;
                case "restore.png": btImage = Resources.restore; break;

                //-----------Item--------------
                case "manage_matrix.png": btImage = Resources.manage_matrix; break;
                case "manage_item.png": btImage = Resources.manage_item; break;
                case "item_details.png": btImage = Resources.item_details; break;
                case "barcode.png": btImage = Resources.barcode; break;
                case "manage_matrix_hover.png": btImage = Resources.manage_matrix_hover; break;
                case "manage_item_hover.png": btImage = Resources.manage_item_hover; break;
                case "item_details_hover.png": btImage = Resources.item_details_hover; break;
                case "barcode_hover.png": btImage = Resources.barcode_hover; break;

            }
            return btImage;
        }


        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            lblTime.Text = String.Format("{0:F}", dt);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ImageChange("click", "body", "tax_hover.png", btnTax);

        }

        void ManagePanel()
        {
            //PanelSetup.Location = new Point(2, 103);
            PanelSetup.Location = PanelCommon.Location;
            PanelSetup.Height = PanelCommon.Height;
            PanelSetup.Width = PanelCommon.Width;
            PanelSetup.Visible = false;
            //=========================================
            PanelItem.Location = PanelCommon.Location;
            PanelItem.Height = PanelCommon.Height;
            PanelItem.Width = PanelCommon.Width;
            PanelItem.Visible = false;
            //=========================================
            PanelStock.Location = PanelCommon.Location;
            PanelStock.Height = PanelCommon.Height;
            PanelStock.Width = PanelCommon.Width;
            PanelStock.Visible = false;
            //=========================================
            PanelKitting.Location = PanelCommon.Location;
            PanelKitting.Height = PanelCommon.Height;
            PanelKitting.Width = PanelCommon.Width;
            PanelKitting.Visible = false;
            //=========================================
            PanelTools.Location = PanelCommon.Location;
            PanelTools.Height = PanelCommon.Height;
            PanelTools.Width = PanelCommon.Width;
            PanelTools.Visible = false;
            //=========================================
          
        }

        void ToggleVisiblePanel()
        {
            PanelCommon.Visible = false;
            PanelSetup.Visible = false;
            PanelItem.Visible = false;
            PanelStock.Visible = false;
            PanelKitting.Visible = false;
            PanelTools.Visible = false;
        }
        #endregion

        private void frmHome_FormClosing(object sender, FormClosingEventArgs e)
        {
            //if (MessageBox.Show("Are you sure to Close this Application..?", "Ken Cloud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            //{
            //    Application.Exit();
            //}
            //else
            //{
            //    this.Show();
            //}
        }

        private void btnLogout_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure to logout?", "Ken Cloud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                frmLogin obj = new frmLogin();
                obj.Show();
                this.Hide();
               
            }
            //{
            // Application.Exit();
            //}

        }

        private void frmHome_FormClosed(object sender, FormClosedEventArgs e)
        {
            //if (MessageBox.Show("Are you sure to Close this Application..?", "Ken Cloud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            //{
            Application.Exit();
            //}
            //else
            //{
            //    this.Show();
            //}
        }

       
      
        private void QCRejectStockRegister_Click(object sender, EventArgs e)
        {
            frmRptQCRejectStockRegister objPage = new frmRptQCRejectStockRegister();
            objPage.Show();
        }

        private void BtnUserRole_Click(object sender, EventArgs e)
        {
            //ImageChange("click", "body", "approve_kit_hover.png", BtnApproveKit);
            frmUserRole objPage = new frmUserRole();
            objPage.TopLevel = false;
            objPage.Visible = true;
            pnlBody.Controls.Clear();
            pnlBody.Controls.Add(objPage);
        }

       
    }
}

Thursday, 27 December 2012

grideview check box checked

 private void DgviewStock_CellContentClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell();
                ch1 = (DataGridViewCheckBoxCell)DgviewStock.Rows[DgviewStock.CurrentRow.Index].Cells[0];

                if (ch1.Value == null)
                    ch1.Value = false;
                switch (ch1.Value.ToString())
                {
                    case "True":
                        ch1.Value = false;
                        panel1.Visible = false;
                        break;

                    case "False":
                        ch1.Value = true;
                        DgviewStock.CurrentCell = DgviewStock.Rows[e.RowIndex].Cells["Copies"];
                        break;
                }
            }
        }

SQL SERVER – Collate – Case Sensitive SQL Query Search

Case Sensitive SQL Query Search
If Column1 of Table1 has following values ‘CaseSearch, casesearch, CASESEARCH, CaSeSeArCh’, following statement will return you all the four records.
SELECT Column1
FROM Table1
WHERE Column1 = 'casesearch'

To make the query case sensitive and retrieve only one record (“casesearch”) from above query, the collation of the query needs to be changed as follows.

SELECT
Column1
FROM Table1
WHERE Column1 COLLATE Latin1_General_CS_AS = 'casesearch'

Adding COLLATE Latin1_General_CS_AS makes the search case sensitive.
Default Collation of the SQL Server installation SQL_Latin1_General_CP1_CI_AS is not case sensitive.
To change the collation of the any column for any table permanently run following query.

ALTER TABLE
Table1
ALTER COLUMN Column1 VARCHAR(20)
COLLATE Latin1_General_CS_AS
To know the collation of the column for any table run following Stored Procedure.

Wednesday, 26 December 2012

barcode link

print in c#.net

 List<ShippingReport> ShippingDetails = new List<ShippingReport>();

        class ShippingReport
        {
            public string FromName { get; set; }
            public string FranchiserName { get; set; }
            public string FromAddress { get; set; }
            public string ToAddress { get; set; }
            public Image ZipBarCode { get; set; }
            public Image CourierBarcode { get; set; }
            public Image FranchiserBarCode { get; set; }
            public string StoreNo { get; set; }
            public Image StoreBarCode { get; set; }
            public Image ShippingBarCode { get; set; }
            public string CourierName { get; set; }
            public string CourierPhone { get; set; }
            public string CourierCode { get; set; }
            public string Quantity { get; set; }
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //Reports.crReportShipping cobj = new Reports.crReportShipping();
            //cobj.SetDataSource(objdml.GetShippingHeader().ToList());
            //Reports.frmReportViewerNew frm = new Reports.frmReportViewerNew();
            //frm.crystalReportViewer1.ReportSource = cobj;
            //frm.ShowDialog();
            lblShippingCode.Text = "A0SRINeck12A0000026";
            if (lblShippingCode.Text != string.Empty)
            {
                GetShippingDetails();
                PrintReport();
            }
        }
        public void GetShippingDetails()
        {
            ShippingReport Shipping = new ShippingReport();
            Shipping.FromName = "Derewala Jewellery International";
            Shipping.FranchiserName = Cobfranchiser.Text;
            Shipping.Quantity = TotalItems();
            Shipping.ShippingBarCode = GenerateShippingBarcode(lblShippingCode.Text);
            Shipping.CourierName = CobCorier.Text;
            Shipping.CourierPhone = lblConPh.Text;
            Shipping.FromAddress = "Sitapura Industrial Area,\nJaipur,Rajsthan";
            string ToAddress = "";
            if (checkBox1.Checked == true)
            {
                Shipping.ZipBarCode = GenerateZipBarcode(LbsZip.Text);
                ToAddress += Lbsaddress1.Text;
                if (Lbsaddress2.Text != "")
                {
                    ToAddress += ",\n" + Lbsaddress2.Text;
                }
                ToAddress += ",\nCity : " + Lbscity.Text + ", State : " + Lbsstate.Text + ",\nZip code : " + LbsZip.Text + ",Country : " + Lbscountry.Text;
                Shipping.ToAddress = ToAddress;
            }
            else
            {
                Shipping.ZipBarCode = GenerateZipBarcode(TxtZip.Text);
                ToAddress += Txtaddress1.Text;
                if (Txtaddress2.Text != "")
                {
                    ToAddress += ",\n" + Txtaddress2.Text;
                }
                ToAddress += ",\nCity : " + CobCity.Text + ", State : " + CobState.Text + ",\nZip code : " + TxtZip.Text + ",Country : " + CobCountry.Text;
                Shipping.ToAddress = ToAddress;
            }
            Shipping.CourierBarcode = GenerateCourierBarcode("9937");
            Shipping.FranchiserBarCode = GenerateFranchiserBarcode("4536");
            Shipping.StoreNo = "2346";
            Shipping.StoreBarCode = GenerateStoreBarcode(Shipping.StoreNo);
            //Shipping.CourierCode=
            ShippingDetails.Add(Shipping);
        }

        private string TotalItems()
        {
            int TotalItems = 0;
            for (int i = 0; i < dglogisitic.Rows.Count; i++)
            {
                TotalItems += int.Parse(dglogisitic.Rows[i].Cells[4].Value.ToString());
            }
            return TotalItems.ToString();
        }

        SwashLibrary.Barcode b = new SwashLibrary.Barcode();

        private Image GenerateZipBarcode(string ZipCode)
        {
            Image GeneratedImg = null;
            try
            {
                int W = 140;
                int H = 60;
                b.Alignment = SwashLibrary.AlignmentPositions.CENTER;
                SwashLibrary.TYPE type = SwashLibrary.TYPE.UNSPECIFIED;
                type = SwashLibrary.TYPE.CODE128B;
                b.IncludeLabel = true;
                b.LabelPosition = SwashLibrary.LabelPositions.TOPCENTER;
                GeneratedImg = b.Encode(type, ZipCode, System.Drawing.Color.Black, System.Drawing.Color.White, W, H);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return GeneratedImg;
        }

        private Image GenerateCourierBarcode(string CourierCode)
        {
            Image GeneratedImg = null;
            try
            {
                int W = 140;
                int H = 60;
                b.Alignment = SwashLibrary.AlignmentPositions.CENTER;
                SwashLibrary.TYPE type = SwashLibrary.TYPE.UNSPECIFIED;
                type = SwashLibrary.TYPE.CODE128B;
                b.IncludeLabel = true;
                b.LabelPosition = SwashLibrary.LabelPositions.TOPCENTER;
                GeneratedImg = b.Encode(type, CourierCode, System.Drawing.Color.Black, System.Drawing.Color.White, W, H);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return GeneratedImg;
        }

        private Image GenerateFranchiserBarcode(string FranchiserCode)
        {
            Image GeneratedImg = null;
            try
            {
                int W = 140;
                int H = 60;
                b.Alignment = SwashLibrary.AlignmentPositions.CENTER;
                SwashLibrary.TYPE type = SwashLibrary.TYPE.UNSPECIFIED;
                type = SwashLibrary.TYPE.CODE128B;
                b.IncludeLabel = true;
                b.LabelPosition = SwashLibrary.LabelPositions.TOPCENTER;
                GeneratedImg = b.Encode(type, FranchiserCode, System.Drawing.Color.Black, System.Drawing.Color.White, W, H);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return GeneratedImg;
        }

        private Image GenerateStoreBarcode(string StoreCode)
        {
            Image GeneratedImg = null;
            try
            {
                int W = 140;
                int H = 60;
                b.Alignment = SwashLibrary.AlignmentPositions.CENTER;
                SwashLibrary.TYPE type = SwashLibrary.TYPE.UNSPECIFIED;
                type = SwashLibrary.TYPE.CODE128B;
                b.IncludeLabel = true;
                b.LabelPosition = SwashLibrary.LabelPositions.TOPCENTER;
                GeneratedImg = b.Encode(type, StoreCode, System.Drawing.Color.Black, System.Drawing.Color.White, W, H);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return GeneratedImg;
        }

        private Image GenerateShippingBarcode(string ShippingCode)
        {
            Image GeneratedImg = null;
            try
            {
                int W = 500;
                int H = 100;
                b.Alignment = SwashLibrary.AlignmentPositions.CENTER;
                SwashLibrary.TYPE type = SwashLibrary.TYPE.UNSPECIFIED;
                type = SwashLibrary.TYPE.CODE128B;
                b.IncludeLabel = true;
                b.LabelPosition = SwashLibrary.LabelPositions.TOPCENTER;
                GeneratedImg = b.Encode(type, ShippingCode, System.Drawing.Color.Black, System.Drawing.Color.White, W, H);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return GeneratedImg;
        }

        private void PrintReport()
        {
            if (System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count <= 0)
            {
                MessageBox.Show("Printer not found");
                return;
            }
            else
            {
                PrintDocument doc = new TextDocument();
                System.Drawing.Printing.PaperSize paperSize = new System.Drawing.Printing.PaperSize();
                paperSize.RawKind = (int)PaperKind.Custom;
                paperSize.Height = 720;
                paperSize.Width = 660;
                doc.DefaultPageSettings.PaperSize = paperSize;
                doc.DefaultPageSettings.Landscape = false;
                doc.DefaultPageSettings.Margins = new Margins(20, 20, 20, 20);
                doc.PrintPage += this.Doc_PrintPage;
                doc.Print();
            }
        }

        class TextDocument : PrintDocument
        {
            public int PageNumber;
            public int Offset;
            public TextDocument()
            {
            }
        }

        private void Doc_PrintPage(object sender, PrintPageEventArgs e)
        {
            TextDocument doc = (TextDocument)sender;
            Font font = new Font("Arial", 10);
            float lineHeight = 70;
            float x = e.MarginBounds.Left;
            float y = e.MarginBounds.Top;
            doc.PageNumber += 1;
            while ((y + lineHeight) < e.MarginBounds.Bottom && doc.Offset < ShippingDetails.Count)
            {
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y, x + 600, y);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y, x, y + 140);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x + 600, y, x + 600, y + 140);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x + 300, y, x + 300, y + 140);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 140, x + 600, y + 140);
                e.Graphics.DrawString("From", new Font("Calibri", 9, FontStyle.Regular), Brushes.Black, x + 10, y + 10);
                e.Graphics.DrawString(ShippingDetails[0].FromName, new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, x + 20, y + 30);
                e.Graphics.DrawString(ShippingDetails[0].FromAddress, new Font("Calibri", 9, FontStyle.Regular), Brushes.Black, x + 20, y + 50);
                e.Graphics.DrawString("To", new Font("Calibri", 9, FontStyle.Regular), Brushes.Black, x + 310, y + 10);
                e.Graphics.DrawString(ShippingDetails[0].FranchiserName, new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, x + 320, y + 30);
                e.Graphics.DrawString(ShippingDetails[0].ToAddress, new Font("Calibri", 9, FontStyle.Regular), Brushes.Black, x + 320, y + 50);
                //e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 140, x + 600, y + 140);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 140, x, y + 280);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x + 600, y, x + 600, y + 280);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x + 300, y, x + 300, y + 280);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 280, x + 600, y + 280);
                e.Graphics.DrawString("SHIP TO POSTAL CODE", new Font("Calibri", 11, FontStyle.Bold), Brushes.Black, x + 5, y + 145);
                Image img;
                img = ShippingDetails[0].ZipBarCode;
                e.Graphics.DrawImage(ShippingDetails[0].ZipBarCode, (300 - (img.Width)) / 2, (280 - img.Height));
                e.Graphics.DrawString("CARRIER", new Font("Calibri", 11, FontStyle.Bold), Brushes.Black, x + 305, y + 145);
                e.Graphics.DrawString(ShippingDetails[0].CourierName, new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, x + 325, y + 165);
                e.Graphics.DrawString("Phone No", new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, x + 325, y + 185);
                e.Graphics.DrawString(":", new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, x + 400, y + 185);
                e.Graphics.DrawString(ShippingDetails[0].CourierPhone, new Font("Calibri", 9, FontStyle.Regular), Brushes.Black, x + 410, y + 185);
                img = ShippingDetails[0].FranchiserBarCode;
                e.Graphics.DrawImage(ShippingDetails[0].CourierBarcode, ((300 - (img.Width)) / 2) + 300, (280 - img.Height));
                //e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 280, x + 600, y + 280);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 280, x, y + 380);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x + 600, y, x + 600, y + 380);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 380, x + 600, y + 380);
                img = ShippingDetails[0].FranchiserBarCode;
                e.Graphics.DrawImage(img, ((300 - (img.Width)) / 2) + 300, y + 282);
                e.Graphics.DrawString("CASE QTY", new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, x + 325, y + img.Height + 300);
                e.Graphics.DrawString(":", new Font("Calibri", 9, FontStyle.Bold), Brushes.Black, x + 390, y + img.Height + 300);
                e.Graphics.DrawString(ShippingDetails[0].Quantity, new Font("Calibri", 9, FontStyle.Regular), Brushes.Black, x + 404, y + img.Height + 300);
                //e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 380, x + 600, y + 380);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 380, x, y + 520);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x + 600, y, x + 600, y + 520);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x + 300, y + 380, x + 300, y + 520);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 520, x + 600, y + 520);
                e.Graphics.DrawString("STORE", new Font("Calibri", 11, FontStyle.Bold), Brushes.Black, x + 10, y + 385);
                img = ShippingDetails[0].StoreBarCode;
                e.Graphics.DrawImage(img, ((300 - (img.Width)) / 2), 400 + ((140 - img.Height) / 2));
                e.Graphics.DrawString("STORE #", new Font("Calibri", 24, FontStyle.Bold), Brushes.Black, x + 315, y + 410);
                e.Graphics.DrawString(ShippingDetails[0].StoreNo, new Font("Calibri", 24, FontStyle.Bold), Brushes.Black, x + 350, y + 480);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 520, x, y + 660);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x + 600, y, x + 600, y + 660);
                e.Graphics.DrawLine(new Pen(Color.Black, 1), x, y + 660, x + 600, y + 660);
                img = ShippingDetails[0].ShippingBarCode;
                e.Graphics.DrawImage(img, ((600 - (img.Width)) / 2), 520 + ((140 - img.Height) / 2));

                //e.Graphics.DrawImage(imgList[doc.Offset], x, y);
                //int off = doc.Offset;
                //doc.Offset += 1;
                //if (doc.Offset < imgList.Count)
                //{
                //    e.Graphics.DrawImage(imgList[doc.Offset], imgList[off].Width + 58, y);
                //}
                doc.Offset += 1;
                y += lineHeight;
            }

            if (doc.Offset < ShippingDetails.Count)
            {
                e.HasMorePages = true;
            }
            else
            {
                doc.Offset = 0;
            }
        }