Пример #1
0
    protected void GrdViewBilit_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            GridViewRow   Row        = GrdViewBilit.SelectedRow;
            string        connection = Request.Cookies["Company"].Value;
            BusinessLogic bl         = new BusinessLogic();
            string        recondate  = Row.Cells[4].Text;
            hdPayment.Value = Convert.ToString(GrdViewBilit.SelectedDataKey.Value);

            if (!bl.IsValidDate(connection, Convert.ToDateTime(recondate)))
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Date is invalid')", true);
                frmViewAdd.Visible = true;
                frmViewAdd.ChangeMode(FormViewMode.ReadOnly);
                return;
            }
            else
            {
                frmViewAdd.Visible = true;
                frmViewAdd.DataBind();
                frmViewAdd.ChangeMode(FormViewMode.Edit);
                UpdatePanel16.Update();
                ModalPopupExtender1.Show();
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Пример #2
0
    protected void frmViewAdd_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        try
        {
            if (e.Exception == null)
            {
                lnkBtnAdd.Visible  = true;
                frmViewAdd.Visible = false;
                System.Threading.Thread.Sleep(1000);
                GrdViewBilit.DataBind();
                //MyAccordion.Visible = true;
                GrdViewBilit.Visible = true;
                UpdatePanel16.Update();
                ModalPopupExtender1.Hide();
                StringBuilder scriptMsg = new StringBuilder();
                scriptMsg.Append("alert('Bilty Saved Successfully.');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), scriptMsg.ToString(), true);
            }
            else
            {
                StringBuilder script = new StringBuilder();
                script.Append("alert('You are not allowed to Update this record. Please contact Supervisor.');");
                e.KeepInInsertMode = true;
                if (e.Exception.InnerException != null)
                {
                    if (e.Exception.InnerException.Message.IndexOf("because they would create duplicate values in the index") != -1)
                    {
                        e.ExceptionHandled = true;
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('ChalanNo and Bilty No. already exists. Please try again.');", true);
                        return;
                    }

                    if (e.Exception.InnerException.Message.IndexOf("Invalid Date") == -1)
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Exception Occured : " + e.Exception.InnerException.Message + "');", true);
                    }
                }

                e.KeepInInsertMode = true;
                e.ExceptionHandled = true;
                lnkBtnAdd.Visible  = false;
                frmViewAdd.Visible = true;
                ModalPopupExtender1.Show();
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Пример #3
0
 protected void UpdateCancelButton_Click(object sender, EventArgs e)
 {
     try
     {
         GrdViewBilit.Visible = true;
         frmViewAdd.Visible   = false;
         lnkBtnAdd.Visible    = true;
         //MyAccordion.Visible = true;
         UpdatePanel16.Update();
         ModalPopupExtender1.Hide();
     }
     catch (Exception ex)
     {
         TroyLiteExceptionManager.HandleException(ex);
     }
 }