public static TSWGift Read(SqlDataReader reader)
    {
        TSWGift retval = new TSWGift();

        for (int i = 0; i < reader.FieldCount; i++)
        {
            switch (reader.GetName(i))
            {
                case "PremInvTransId":
                    retval.PremID = Helper.ToInt32(reader[i]);
                    break;
                case "PersonnelID":
                    retval.PersonnelID = Helper.ToString(reader[i]);
                    break;
                case "GiftCharge":
                    retval.GiftCharge = Helper.ToDecimal(reader[i]);
                    break;
                case "TourID":
                    retval.TourID = Helper.ToInt32(reader[i]);
                    break;
                case "VoidVoucher":
                    retval.VoidVoucher = Helper.ToString(reader[i]);
                    break;
                case "Budget":
                    retval.Budget = Helper.ToInt32(reader[i]);
                    break;
                case "PremName":
                    retval.PremName = Helper.ToString(reader[i]);
                    break;
                case "PremCount":
                    retval.Qty = Helper.ToInt32(reader[i]);
                    break;
                case "Siteid":
                    retval.SiteId = Helper.ToInt32(reader[i]);
                    break;
                case "LastName":
                    retval.LastName = Helper.ToString(reader[i]);
                    break;
                case "FirstName":
                    retval.FirstName = Helper.ToString(reader[i]);
                    break;
                case "Personnel":
                    retval.Personnel = Helper.ToString(reader[i]);
                    break;
                case "TourStatus":
                    retval.TourStatus = Helper.ToString(reader[i]);
                    break;
            }
        }
        return retval;
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        TSWGift item = new TSWGift();
        item.PremID = Helper.ToInt32(lblPremID.Text);
        item.PersonnelID = Helper.ToString(ddlPersonnel.SelectedValue);
        item.GiftCharge = Helper.ToDecimal(txtGiftCharge.Text);
        item.Budget = Helper.ToDecimal(txtBdgt.Text);
        item.UserID = Helper.ToString(Session["UserId"]);

        //throw new Exception(item.PremID + "-" + item.PersonnelID + "-" + item.GiftCharge + "-" + item.Budget);

        TSWGiftDB.UpdateTSWGift(item);

        //update the grid

        GridView1.DataBind();
        lblCount.Text = GridView1.Rows.Count.ToString() + " records on this page. ";
        lblMessages.Text = "Information Updated Successfully: <b><font color='blue'>" + lblPremID.Text + "</font></b>";
        ClearItems();
        PnlDetail.Visible = false;
    }
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        TSWGift item = new TSWGift();

        //Perform the update
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            GridViewRow row = GridView1.Rows[i];
            bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

            if (isChecked)
            {
                item.PremID = Helper.ToInt32(GridView1.Rows[i].Cells[1].Text.Trim());
                item.UserID = Helper.ToString(Session["UserId"]);
                TSWGiftDB.UpdateTSWGiftVoidVoucher(item);
            }
        }
        GridView1.DataBind();
        CountRecords();
        pnlSummary.Visible = false;
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        TSWGift item = new TSWGift();
        item.PremID = Helper.ToInt32(lblPITI.Text);

        if (chkVoid.Checked == true)
        {
            item.PremID = Helper.ToInt32(lblPITI.Text);
        }

        TSWGiftDB.UpdateTSWGiftVoidVoucher(item);

        //update the grid

        GridView1.DataBind();
        lblMessage.Text = GridView1.Rows.Count.ToString() + " records on this page. ";
        lblMessage.Text = "Your information has been saved for PremID  <b><font color='blue'>" + lblPITI.Text + "</font></b>";
        ClearItems();
        //Are you sure you want to void this item. Once voided it's not going to show in this list anymore
    }
    public static void UpdateTSWGiftVoidVoucher(TSWGift value)
    {
        SqlParameter[] param = new SqlParameter[] {
            new SqlParameter("@PremID", value.PremID),
            new SqlParameter("@User", value.UserID)

        };

        SqlHelper.ExecuteNonQuery(Helper.ConnectionStringR, CommandType.StoredProcedure, "usp_CxcTrackerVoid", param);
    }
 public static void UpdateTSWGift(TSWGift value)
 {
     SqlParameter[] param = new SqlParameter[] {
         new SqlParameter("@PremID", value.PremID),
         new SqlParameter("@PersID", Helper.ToInt32(value.PersonnelID)),
         new SqlParameter("@Charge", value.GiftCharge),
         new SqlParameter("@Bdgt", value.Budget),
         new SqlParameter("@User", value.UserID)
     };
     //throw new Exception(value.PremID + "-" + value.PersonnelID + "-" + value.GiftCharge + "-" + value.Budget);
     SqlHelper.ExecuteNonQuery(Helper.ConnectionStringR, CommandType.StoredProcedure, "usp_CxcTrackerUpdater", param);
 }