public void BindValues()
        {
            TowelHiringMaster objTowelMaster = AssignTowelController.GetAssignedTowelById(TowelMasterId);

            BindMembers();
            BindTowelPackages();

            drpMembers.SelectedValue       = Convert.ToString(objTowelMaster.memberId);
            drpTowelPackages.SelectedValue = Convert.ToString(objTowelMaster.towelPackageId);
            drpTowelPackages.Enabled       = drpMembers.Enabled = false;

            txtStDate.Text     = ((DateTime)objTowelMaster.startDate).ToString("dd/MM/yyyy");
            txtStDate.ReadOnly = true;
            txtEndDate.Text    = ((DateTime)objTowelMaster.endDate).ToString("dd/MM/yyyy");

            pnlAssignValues.Visible = true;
            TowelPackageId          = Convert.ToInt64(drpTowelPackages.SelectedValue);
            txtHireRem.Text         = BindHiringTime();
            BindTowelPacakgesValues();

            MemberId = Convert.ToInt64(drpMembers.SelectedValue);
            BindMemberValues();

            chkPaidRet.Checked = objTowelMaster.isPaid;
            if (chkPaidRet.Checked)
            {
                pnlPayment.Visible = true;
                BindPayMode();
                rblPayMode.SelectedValue = Convert.ToString(objTowelMaster.paymentMode);
                rblPayMode.Enabled       = chkPaidRet.Enabled = false;
            }
        }
 protected void grdAssignedPackages_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "EditTowelMember")
         {
             Mode          = "Update";
             TowelMasterId = Convert.ToInt32(e.CommandArgument);
             TowelHiringMaster objTowel = AssignTowelController.GetAssignedTowelById(TowelMasterId);
             MemberId = objTowel.memberId;
             PanelVisibility(false, true, false);
             BindValues();
         }
         else if (e.CommandName == "DetailTowelMember")
         {
             TowelMasterId = Convert.ToInt32(e.CommandArgument);
             TowelHiringMaster objTowel = AssignTowelController.GetAssignedTowelById(TowelMasterId);
             MemberId = objTowel.memberId;
             PanelVisibility(false, false, true);
             BindTransaction();
         }
         else if (e.CommandName == "DeleteTowelMember")
         {
             TowelMasterId = Convert.ToInt32(e.CommandArgument);
             new AssignTowelController().DeleteTowelMember(TowelMasterId);
             BindGrid();
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "succ_msg", "MessageBox('Success','Data Deleted Successfully');", true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void BindTransaction()
 {
     try
     {
         grdTrans.DataSource = AssignTowelController.GetAssignedTransaction(TowelMasterId);
         grdTrans.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public bool IfPrevAssigned()
 {
     try
     {
         TowelHiringMaster objPTPMember = AssignTowelController.GetAssignedTowelByMemberIdAndPackageId(MemberId, TowelPackageId);
         return(objPTPMember != null ? true : false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void BindGrid()
 {
     try
     {
         grdAssignedPackages.DataSource = AssignTowelController.GetAssignedTowel(SortDir, SortField, txtRfidNo.Text, txtSearch.Text, LoginUser.ClubId);
         grdAssignedPackages.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void BindTowelPackages()
 {
     try
     {
         drpTowelPackages.DataSource     = AssignTowelController.GetPackages();
         drpTowelPackages.DataTextField  = "packageName";
         drpTowelPackages.DataValueField = "ID";
         drpTowelPackages.DataBind();
         drpTowelPackages.Items.Insert(0, new ListItem("Select Package", "0"));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 protected void grdTrans_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "EditTowelTrans")
         {
             int TowelTransid = Convert.ToInt32(e.CommandArgument);
             TowelTransaction objTowelTrans = AssignTowelController.GetTransById(TowelTransid);
             objTowelTrans.isTowelReturn = true;
             new AssignTowelController().UpdateTransaction(objTowelTrans);
             BindTransaction();
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "succ_msg", "MessageBox('Success','Towel Returned Successfully');", true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public string BindHiringTime()
        {
            try
            {
                int  Trans      = 0;
                long HiringTime = 0;

                TowelHiringPackage objTowelPackage = TowelPackageController.GetTowelPackageById(TowelPackageId);
                txtAmt.Text = Convert.ToString(objTowelPackage.amount);
                HiringTime  = objTowelPackage.hiringTime;
                if (AssignTowelController.GetTransByMemberAndTowelMasterId(MemberId, TowelMasterId) != null)
                {
                    Trans      = AssignTowelController.GetTransByMemberAndTowelMasterId(MemberId, TowelMasterId).Count;
                    HiringTime = HiringTime - Trans;
                }
                return(HiringTime.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void UpdateTowelMaster()
 {
     try
     {
         TowelHiringMaster objTowelMember = AssignTowelController.GetAssignedTowelById(TowelMasterId);
         objTowelMember.towelPackageId   = Convert.ToInt64(drpTowelPackages.SelectedValue);
         objTowelMember.memberId         = Convert.ToInt64(drpMembers.SelectedValue);
         objTowelMember.startDate        = UtillController.ConvertDateTime(txtStDate.Text);
         objTowelMember.endDate          = UtillController.ConvertDateTime(txtEndDate.Text);
         objTowelMember.hiringTimeUpdate = Convert.ToInt32(txtHiringTime.Text);
         objTowelMember.amount           = Convert.ToDecimal(txtAmt.Text);
         objTowelMember.paymentMode      = null;
         objTowelMember.chequeDate       = null;
         objTowelMember.chequeNo         = objTowelMember.bankName = objTowelMember.branchDetails = null;
         objTowelMember.isPaid           = false;
         objTowelMember = new AssignTowelController().UpdateTowelMember(objTowelMember);
         ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "succ_msg", "MessageBox('Success','Package Updated Successfully');", true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void InsertTransaction()
        {
            try
            {
                TowelHiringMaster objTowelMaster = AssignTowelController.GetAssignedTowelById(TowelMasterId);
                TowelTransaction  objTowelTrans  = new TowelTransaction();
                long hiringTime = 0;
                objTowelTrans.towelHiriningId = TowelMasterId;
                objTowelTrans.memberId        = MemberId;
                objTowelTrans.depositAmount   = objTowelMaster.TowelHiringPackage.depositAmount;
                objTowelTrans.isTowelGiven    = true;
                objTowelTrans.isTowelReturn   = false;
                objTowelTrans = new AssignTowelController().InsertTransaction(objTowelTrans);

                hiringTime = objTowelMaster.hiringTimeUpdate - 1;
                objTowelMaster.hiringTimeUpdate = (int)hiringTime;
                objTowelMaster = new AssignTowelController().UpdateTowelMember(objTowelMaster);
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "succ_msg", "MessageBox('Success','Hiring Time Added Successfully');", true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }