protected void lnkbtnSave_OnClick(object sender, EventArgs e)
        {
            BindDropdownDAL    objDropDal   = new BindDropdownDAL();
            Int64              StckDetlIdno = 0;
            VechDetlClmPrtyDAL objDAL       = new VechDetlClmPrtyDAL();
            Int32              intYearIdno  = string.IsNullOrEmpty(Convert.ToString(ddlDateRange.SelectedValue)) ? 0 : Convert.ToInt32(ddlDateRange.SelectedValue);
            Int64              intLocIdno   = string.IsNullOrEmpty(Convert.ToString(ddlLocation.SelectedValue)) ? 0 : Convert.ToInt64(ddlLocation.SelectedValue);
            Int64              intItemIdno  = string.IsNullOrEmpty(Convert.ToString(ddlItemName.SelectedValue)) ? 0 : Convert.ToInt64(ddlItemName.SelectedValue);
            string             strSerialNo  = string.IsNullOrEmpty(Convert.ToString(txtSerialNo.Text)) ? "" : Convert.ToString(txtSerialNo.Text);
            string             strCompName  = string.IsNullOrEmpty(Convert.ToString(txtCompName.Text)) ? "" : Convert.ToString(txtCompName.Text);
            string             strPurFrom   = string.IsNullOrEmpty(Convert.ToString(txtPurchaseFrom.Text)) ? "" : Convert.ToString(txtPurchaseFrom.Text);
            Int32              intTyreType  = string.IsNullOrEmpty(Convert.ToString(ddltype.SelectedValue)) ? 0 : Convert.ToInt32(ddltype.SelectedValue);
            Int64              intAcntIdno  = string.IsNullOrEmpty(Convert.ToString(ddltype.SelectedValue)) ? 0 : Convert.ToInt64(ddltype.SelectedValue);
            double             ddlOpenRate  = string.IsNullOrEmpty(Convert.ToString(txtOpenRate.Text.Trim())) ? 0 : Convert.ToDouble(txtOpenRate.Text.Trim());
            //Check Conditions Before Save Peeyush Kasuhik
            var lst1 = objDropDal.CheckSerialNo(strSerialNo);

            if (lst1 != null && lst1 > 0)
            {
                ShowMessageErr("Serial No already Exists !"); return;
            }
            if (string.IsNullOrEmpty(hidstckidno.Value) == true)
            {
                StckDetlIdno = objDAL.Insert(strSerialNo, intLocIdno, intItemIdno, strCompName, intTyreType, strPurFrom, intYearIdno, ddlOpenRate, (string.IsNullOrEmpty(Convert.ToString(Request.QueryString["AcntIdno"])) ? 0 : Convert.ToInt64(Request.QueryString["AcntIdno"])));
            }
            else
            {
                StckDetlIdno = objDAL.Update((string.IsNullOrEmpty(Convert.ToString(hidstckidno.Value)) ? 0 : Convert.ToInt64(hidstckidno.Value)), strSerialNo, intLocIdno, intItemIdno, strCompName, intTyreType, strPurFrom, intYearIdno, ddlOpenRate, (string.IsNullOrEmpty(Convert.ToString(Request.QueryString["AcntIdno"])) ? 0 : Convert.ToInt64(Request.QueryString["AcntIdno"])));
            }
            if (StckDetlIdno == 0)
            {
                ShowMessageErr("Record  Not Saved ");
            }
            else if (StckDetlIdno == -1)
            {
                ShowMessageErr("Record already exists.");
            }
            else if (StckDetlIdno > 0)
            {
                if (hidstckidno.Value == "")
                {
                    ShowMessage("Record Saved Successfully");
                }
                else
                {
                    ShowMessage("Record Updated Successfully.");
                }
                this.ClearControls();
                this.BindGrid();
            }
        }
        protected void lnkbtnSave_Click(object sender, EventArgs e)
        {
            string   msg       = "";
            DateTime?ClaimDate = null;

            ClaimDate      = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtClaimDate.Text));
            objClaimFrmDAL = new ClaimToDAL();
            DateTime CurrentDate = System.DateTime.Now;

            if (grdMain.Rows.Count > 0)
            {
                DTMain = CreateDt();
                if (rdoAgnReceived.Checked)
                {
                    foreach (GridViewRow row in grdMain.Rows)
                    {
                        Label        lblGridSerialNo = (Label)row.FindControl("lblGridSerialNo");
                        TextBox      txtNewSerialNo  = (TextBox)row.FindControl("txtNewSerialNo");
                        DropDownList ddlStatus       = (DropDownList)row.FindControl("ddlStatus");

                        if (txtNewSerialNo.Text.Trim() == "")
                        {
                            ShowMessageErr("Please Fill Serial Number."); txtNewSerialNo.Focus(); return;
                        }
                        if (lblGridSerialNo.Text.Trim() == txtNewSerialNo.Text.Trim())
                        {
                            ShowMessageErr("New Serial Not same as old Serial,Check New Serial No." + txtNewSerialNo.Text.Trim() + ""); txtNewSerialNo.Focus(); return;
                        }
                        if (ddlStatus.SelectedValue == "1")
                        {
                            ShowMessageErr("Please Check Status should not be submitted."); ddlStatus.Focus(); return;
                        }
                        BindDropdownDAL obj = new BindDropdownDAL();
                        if (Request.QueryString["ClaimHeadIdno"] == null)
                        {
                            if (txtNewSerialNo.Text.Trim() != "")
                            {
                                Int64 Count = obj.CheckSerialNo(txtNewSerialNo.Text.Trim());
                                if (Count != 0)
                                {
                                    ShowMessageErr("Serial Number :" + txtNewSerialNo.Text.Trim() + " already exists in stock.");
                                    txtNewSerialNo.Focus();
                                    return;
                                }
                            }
                        }
                    }
                }

                foreach (GridViewRow row in grdMain.Rows)
                {
                    HiddenField  hidSerialIdno       = (HiddenField)row.FindControl("hidSerialIdno");
                    HiddenField  hidClaimIdno        = (HiddenField)row.FindControl("hidClaimIdno");
                    Label        txtDefRemark        = (Label)row.FindControl("lblGridDefectNo");
                    Label        txtVchAppDetl       = (Label)row.FindControl("lblGridVehDetlNo");
                    DropDownList ddlStatus           = (DropDownList)row.FindControl("ddlStatus");
                    TextBox      txtRemarks          = (TextBox)row.FindControl("txtRemarks");
                    TextBox      txtNewSerialNo      = (TextBox)row.FindControl("txtNewSerialNo");
                    HiddenField  HidClaimDetailsIdno = (HiddenField)row.FindControl("HidClaimDetailsIdno");

                    ApplicationFunction.DatatableAddRow(DTMain, row.RowIndex + 1, hidSerialIdno.Value, hidClaimIdno.Value, txtDefRemark.Text.Trim(), txtVchAppDetl.Text.Trim(), ddlStatus.SelectedValue, txtRemarks.Text.Trim(), txtNewSerialNo.Text.Trim(), HidClaimDetailsIdno.Value);
                }
                if (rdoAgnReceived.Checked)
                {
                    foreach (GridViewRow rows in grdMain.Rows)
                    {
                        TextBox   txtNewSerialNo1 = (TextBox)rows.FindControl("txtNewSerialNo");
                        DataRow[] drs             = DTMain.Select("NewSerialNo='" + txtNewSerialNo1.Text.Trim() + "'");
                        if (drs.Length > 1)
                        {
                            ShowMessageErr("Serial Number :" + txtNewSerialNo1.Text.Trim() + " already exists in list.");
                            txtNewSerialNo1.Focus();
                            return;
                        }
                    }
                }

                tblClaimToComHead objClaimHead = new tblClaimToComHead();

                if (rdoAgnReceived.Checked)
                {
                    if (txtClaimDate.Text == "")
                    {
                        objClaimHead.ClaimToComRec_Date = null;
                    }
                    else
                    {
                        objClaimHead.ClaimToComRec_Date = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtClaimDate.Text));
                    }
                }
                else
                {
                    if (txtClaimDate.Text == "")
                    {
                        objClaimHead.ClaimToComHead_Date = null;
                    }
                    else
                    {
                        objClaimHead.ClaimToComHead_Date = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtClaimDate.Text));
                    }
                }
                objClaimHead.ClaimToCom_No  = string.IsNullOrEmpty(Convert.ToString(txtClaimNo.Text.Trim())) ? 0 : Convert.ToInt64(txtClaimNo.Text.Trim());
                objClaimHead.ClaimHead_Idno = string.IsNullOrEmpty(Convert.ToString(HidClaimHeadIdno.Value)) ? 0 : Convert.ToInt64(HidClaimHeadIdno.Value);
                objClaimHead.Prefix_No      = string.IsNullOrEmpty(Convert.ToString(txtPrefixNo.Text.Trim())) ? "" : Convert.ToString(txtPrefixNo.Text.Trim());
                objClaimHead.FromLoc_Idno   = string.IsNullOrEmpty(Convert.ToString(ddlFromCity.SelectedValue)) ? 0 : Convert.ToInt64(ddlFromCity.SelectedValue);
                objClaimHead.Year_Idno      = string.IsNullOrEmpty(Convert.ToString(ddlDateRange.SelectedValue)) ? 0 : Convert.ToInt64(ddlDateRange.SelectedValue);
                objClaimHead.Prty_Idno      = string.IsNullOrEmpty(Convert.ToString(ddlParty.SelectedValue)) ? 0 : Convert.ToInt64(ddlParty.SelectedValue);
                objClaimHead.Comp_Idno      = string.IsNullOrEmpty(Convert.ToString(ddlCompanyName.SelectedValue)) ? 0 : Convert.ToInt64(ddlCompanyName.SelectedValue);

                Int64 Against = 0; if (rdoAgnSend.Checked)
                {
                    Against = 1;
                }
                else
                {
                    Against = 2;
                }
                objClaimHead.Against = Against;
                Int64 value = 0;
                using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (string.IsNullOrEmpty(hidid.Value) == true)
                    {
                        objClaimHead.Date_Added = System.DateTime.Now;
                        value          = objClaimFrmDAL.Insert(objClaimHead, DTMain);
                        objClaimFrmDAL = null;
                    }
                    else
                    {
                        objClaimHead.Date_Modified = System.DateTime.Now;
                        lnkbtnNew.Visible          = false;
                        if (rdoAgnReceived.Checked)
                        {
                            value = objClaimFrmDAL.UpdateForRecvd(objClaimHead, Convert.ToInt32(hidid.Value), DTMain);
                        }
                        else
                        {
                            value = objClaimFrmDAL.Update(objClaimHead, Convert.ToInt32(hidid.Value), DTMain);
                        }

                        objClaimFrmDAL = null;
                    }

                    if (string.IsNullOrEmpty(hidid.Value) == false)
                    {
                        if (value > 0 && (string.IsNullOrEmpty(hidid.Value) == false))
                        {
                            ShowMessage("Record Update successfully");
                            Clear();
                            tScope.Complete();
                        }
                        else if (value == -1)
                        {
                            ShowMessageErr("Claim Number Already Exist");
                            tScope.Dispose();
                        }
                        else
                        {
                            ShowMessageErr("Record  Not Update");
                            tScope.Dispose();
                        }
                    }
                    else
                    {
                        if (value > 0 && (string.IsNullOrEmpty(hidid.Value) == true))
                        {
                            ShowMessage("Record  saved Successfully ");
                            Clear();
                            tScope.Complete();
                        }
                        else if (value == -1)
                        {
                            ShowMessageErr("Claim Number Already Exist");
                            tScope.Dispose();
                        }
                        else
                        {
                            ShowMessageErr("Record Not  saved Successfully ");
                            tScope.Dispose();
                        }
                    }
                }
            }
            else
            {
                ShowMessageErr("Please Search and Select Serial Number.");
                return;
            }
        }