Esempio n. 1
0
    protected void grdvwViewAsset_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        ///Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            GridViewRow row = (GridViewRow)grdvwViewAsset.Rows[e.RowIndex];

            int assetid = Int32.Parse(grdvwViewAsset.DataKeys[e.RowIndex].Value.ToString());

            TextBox txtTagNo = (TextBox)row.FindControl("txtTagNo");

            TextBox txtPONo = (TextBox)row.FindControl("txtPONo");

            TextBox txtOwner = (TextBox)row.FindControl("txtOwner");

            TextBox txtLocation = (TextBox)row.FindControl("txtLocation");

            TextBox txtCompanyCode = (TextBox)row.FindControl("txtCompanyCode");

            TextBox txtPurchaseDate = (TextBox)row.FindControl("txtPurchaseDate");

            TextBox txtAssetCategory = (TextBox)row.FindControl("txtAssetCategory");
            TextBox txtRemarks       = (TextBox)row.FindControl("txtRemarks");

            DropDownList ddlstock = (DropDownList)row.FindControl("ddlstock");

            Label lblmanual = (Label)row.FindControl("lblmanual");

            ObjAsset.Assetid  = assetid;
            ObjAsset.TagNo    = txtTagNo.Text;
            ObjAsset.PONo     = txtPONo.Text;
            ObjAsset.location = txtLocation.Text;
            //if (lblmanual.Text == "Yes")
            //{
            ObjAsset.IsInStock   = Convert.ToBoolean(ddlstock.SelectedValue);
            ObjAsset.AssetOwner  = txtOwner.Text;
            ObjAsset.CompanyCode = txtCompanyCode.Text;
            //if (txtPurchaseDate.Text.Trim() != "")
            //{
            //    ObjAsset.PurchaseDate = DateTime.ParseExact(txtPurchaseDate.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString();
            //}
            //else
            //{
            //    ObjAsset.PurchaseDate = null;
            //}
            //ObjAsset.PurchaseDate = txtPurchaseDate.Text;
            if (txtPurchaseDate.Text.ToString() != "")
            {
                ObjAsset.PurchaseDate = txtPurchaseDate.Text.ToString();
            }
            else
            {
                ObjAsset.PurchaseDate = null;
            }
            //ObjAsset.PurchaseDate = ((DateTime)returnData["PurchaseDate"]).ToString();
            ObjAsset.AssetCategory = txtAssetCategory.Text;
            ObjAsset.Remarks       = txtRemarks.Text;


            ObjAsset.Update_Asset_mst_Tag_PO_By_id();
            //}
            //else if (ddlstock.SelectedValue == "True" && lblmanual.Text == "No")
            //{
            //    ObjAsset.IsInStock = Convert.ToBoolean(ddlstock.SelectedValue);
            //    ObjAsset.AssetOwner = txtOwner.Text;

            //    ObjAsset.Update_Asset_mst_Tag_PO_By_id();

            //}
            //else
            //{
            //    ObjAsset.AssetOwner = txtOwner.Text;

            //    ObjAsset.Update_Asset_mst_Tag_PO_IsInStockBy_id();

            //}
            //if (DdlOwner.SelectedItem.Text == "Other")
            //{

            // Refresh the data
            grdvwViewAsset.EditIndex = -1;
            BindGrid1();
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }