void LoadLibraryMaterialToEdit(ATTLibraryMaterial library)
    {
        Session["LM_LibraryMaterial"] = library;

        Session["LibMatID"]                 = library.LMaterialID;
        this.ddlOrg.SelectedValue           = library.OrgID.ToString();
        this.ddlLibrary.SelectedValue       = library.LibraryID.ToString();
        this.ddlCategory_Rqd.SelectedValue  = library.LibraryMaterialCategory.ToString();
        this.ddlType_Rqd.SelectedValue      = library.LibraryMaterialType.ToString();
        this.txtCallNo_Rqd.Text             = library.CallNo;
        this.ddlLanguage_Rqd.SelectedValue  = library.LanguageID.ToString();
        this.ddlPublisher_Rqd.SelectedValue = library.PublisherID.ToString();
        this.txtCorporateBody.Text          = library.CorporateBody;
        this.txtTitle_Rqd.Text              = library.Title;
        this.txtSeriesState.Text            = library.SeriesStatement;
        this.txtNote.Text           = library.Note;
        this.txtBrdSubHeading.Text  = library.BoardSubjectHeading;
        this.txtGeoDescription.Text = library.GeoDescription;
        this.txtPhyDescription.Text = library.PhysicalDescription;

        library.LstLMKeyword       = BLLLibraryMaterialKeyword.GetLibraryMaterialKeywordList(library.OrgID, library.LibraryID, library.LMaterialID);
        this.grdKeyword.DataSource = library.LstLMKeyword;
        this.grdKeyword.DataBind();

        library.LstLMAuthor       = BLLLibraryMaterialAuthor.GetLibraryMaterialAuthorList(library.OrgID, library.LibraryID, library.LMaterialID);
        this.grdAuthor.DataSource = library.LstLMAuthor;
        this.grdAuthor.DataBind();
    }
    void LoadLibraryMaterialCopyGrid(long LMID)
    {
        ATTLibraryMaterial            LMObj  = (ATTLibraryMaterial)Session["LM"];
        List <ATTLibraryMaterialCopy> LMCopy = BLLLibraryMaterialCopy.GetLMCopy(LMObj.OrgID, LMObj.LibraryID, LMID);

        libMatCopyGrd.DataSource = LMCopy;
        libMatCopyGrd.DataBind();
        Session["LMCopy"] = LMCopy;
    }
    void LoadLibraryMaterialCopy(ATTLibraryMaterial library)
    {
        //Session["LMCopy"] = library.LstLMCopy;
        List <ATTLibraryMaterialCopy> LstLibCpy = BLLLibraryMaterialCopy.GetLMCopy(library.OrgID, library.LibraryID, library.LMaterialID);

        Session["LMCopy"]             = LstLibCpy;
        this.libMatCopyGrd.DataSource = LstLibCpy;
        this.libMatCopyGrd.DataBind();
    }
 public static long AddLibraryMaterial(ATTLibraryMaterial obj, Previlege pobj)
 {
     try
     {
         return(DLLLibraryMaterial.AddLibraryMaterial(obj, pobj));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.hdnPagingIndex.Value == "")
            {
                this.hdnPagingIndex.Value = "0";
            }
            else
            {
                this.hdnPagingIndex.Value = (int.Parse(this.hdnPagingIndex.Value) + 1).ToString();
            }

            string keywordCollection = this.GetCriteriaCollectionFromList(this.lstKeyword);
            string authorCollection  = this.GetCriteriaCollectionFromList(this.lstAuthor);

            ATTLibraryMaterial obj = new ATTLibraryMaterial();

            obj.OrgID                   = int.Parse(this.ddlOrg.SelectedValue);
            obj.LibraryID               = int.Parse(this.ddlLibrary.SelectedValue);
            obj.LibraryMaterialType     = int.Parse(this.ddlType.SelectedValue);
            obj.LibraryMaterialCategory = int.Parse(this.ddlCategory.SelectedValue);
            obj.LanguageID              = int.Parse(this.ddlLanguage.SelectedValue);
            obj.PublisherID             = int.Parse(this.ddlPublisher.SelectedValue);
            obj.CallNo                  = this.txtCallNo.Text;

            Session["LibraryMaterialEditor"] = BLLLibraryMaterial.GetSearchedLibraryMaterialList(obj, keywordCollection, authorCollection, "M");
            this.grdSearch.DataSource        = (List <ATTLibraryMaterial>)Session["LibraryMaterialEditor"];
            this.grdSearch.DataBind();
            this.lblRecordCount.Text = "Total " + this.grdSearch.Rows.Count.ToString() + " record found.";

            this.LoadImageX.Width  = new Unit(0);
            this.LoadImageX.Height = new Unit(0);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    void SaveLibraryDetails(long?LibMatID, string action, long acc_id)
    {
        long LMID = 0;

        if (LibMatID == null)
        {
            LMID = long.Parse(Session["LibMatID"].ToString());
        }
        else
        {
            LMID = LibMatID.Value;
        }

        ATTLibraryMaterial LMObj = (ATTLibraryMaterial)Session["LM"];
        ////---------Add Material Copy---------
        ATTLibraryMaterialCopy libCopyObj = new ATTLibraryMaterialCopy();

        libCopyObj.Edition          = editionTxt.Text;
        libCopyObj.PublicationDate  = pubDateTxt.Text;
        libCopyObj.RegistrationDate = DateTime.Now;
        regDateTxt.Text             = DateTime.Now.ToShortDateString();
        libCopyObj.Price            = double.Parse(priceTxt.Text);
        libCopyObj.CurrencyID       = int.Parse(this.ddlCurrency.SelectedValue);
        libCopyObj.Location         = locTxt.Text;
        libCopyObj.Action           = action;
        libCopyObj.AccessionID      = acc_id;
        libCopyObj.IsbnIssnNo       = isbnTxt.Text;
        libCopyObj.OrgID            = LMObj.OrgID;
        libCopyObj.LibraryID        = LMObj.LibraryID;
        libCopyObj.EntryBy          = LMObj.EntryBy;

        List <ATTLibraryMaterialCopy> lstLMCpy = new List <ATTLibraryMaterialCopy>();

        lstLMCpy.Add(libCopyObj);
        BLLLibraryMaterial.AddLibraryMaterialCopy(lstLMCpy, LMID);
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (this.hdnAction.Value == "")
        {
            if (!ServerValidateAll())
            {
                this.lblStatusMessage.Text = sb.ToString();
                this.programmaticModalPopup.Show();
                return;
            }
        }
        else if (this.hdnAction.Value == "M")
        {
            if (!ServerValidateMaster())
            {
                this.lblStatusMessage.Text = sb.ToString();
                this.programmaticModalPopup.Show();
                return;
            }
        }
        string ext = System.IO.Path.GetExtension(this.fupAttachment.FileName);

        if (ext == "pdf" || ext == "jpeg" || ext == "jpg" || ext == "gif")
        {
            this.lblStatusMessage.Text = "Uploaded file's extention must be of 'pdf' or 'jpg' or 'jpeg' or 'gif'.";
            this.programmaticModalPopup.Show();
            return;
        }

        ATTLibraryMaterial LM = (ATTLibraryMaterial)Session["LM_LibraryMaterial"];

        LM.OrgID     = int.Parse(this.ddlOrg.SelectedValue);
        LM.LibraryID = int.Parse(this.ddlLibrary.SelectedValue);
        if (this.hdnAction.Value != "M")
        {
            LM.LMaterialID = 0;
        }
        LM.LibraryMaterialType     = int.Parse(this.ddlType_Rqd.SelectedValue);
        LM.LibraryMaterialCategory = int.Parse(this.ddlCategory_Rqd.Text);
        LM.CallNo              = this.txtCallNo_Rqd.Text;
        LM.CorporateBody       = this.txtCorporateBody.Text;
        LM.Title               = this.txtTitle_Rqd.Text;
        LM.SeriesStatement     = this.txtSeriesState.Text;
        LM.Note                = this.txtNote.Text;
        LM.BoardSubjectHeading = this.txtBrdSubHeading.Text;
        LM.GeoDescription      = this.txtGeoDescription.Text;
        LM.LanguageID          = int.Parse(this.ddlLanguage_Rqd.SelectedValue);
        LM.PublisherID         = int.Parse(this.ddlPublisher_Rqd.SelectedValue);
        LM.PhysicalDescription = this.txtPhyDescription.Text;
        LM.EntryBy             = ((ATTUserLogin)Session["Login_User_Detail"]).UserName;
        LM.EntryOn             = DateTime.Now;
        //LM.ContentFile = null;
        //LM.CFileType = "";
        if (this.hdnAction.Value == "M")
        {
            LM.Action = "M";
        }
        else
        {
            LM.Action = "A";
        }

        if (this.fupAttachment.HasFile == true)
        {
            LM.ContentFile = this.fupAttachment.FileBytes;
            LM.CFileType   = System.IO.Path.GetExtension(this.fupAttachment.FileName);
        }

        ObjectValidation OV = BLLLibraryMaterial.Validate(LM);

        if (OV.IsValid == false)
        {
            //this.lblMaterialStatus.Text = OV.ErrorMessage;
            this.lblStatusMessage.Text = OV.ErrorMessage;
            this.programmaticModalPopup.Show();
            return;
        }

        GridViewRow keyRow;
        int         keyRowCount = 0;
        bool        keyChecked;

        foreach (ATTLibraryMaterialKeyword ky in LM.LstLMKeyword)
        {
            keyRow = this.grdKeyword.Rows[keyRowCount];

            keyChecked = ((CheckBox)keyRow.FindControl("chkKeyword")).Checked;
            if (keyChecked == true && ky.Action == "A")
            {
                ky.Action = "N";
            }
            else if (keyChecked == true && ky.Action == "M")
            {
                ky.Action = "D";
            }
            else if (keyChecked == false && ky.Action == "M")
            {
                ky.Action = "N";
            }

            keyRowCount = keyRowCount + 1;
        }

        GridViewRow authorRow;
        int         authorRowCount = 0;
        bool        authorChecked;

        foreach (ATTLibraryMaterialAuthor au in LM.LstLMAuthor)
        {
            authorRow = this.grdAuthor.Rows[authorRowCount];

            authorChecked = ((CheckBox)authorRow.FindControl("chkAuthor")).Checked;
            if (authorChecked == true && au.Action == "A")
            {
                au.Action = "N";
            }
            else if (authorChecked == true && au.Action == "M")
            {
                au.Action = "D";
            }
            else if (authorChecked == false && au.Action == "M")
            {
                au.Action = "N";
            }

            authorRowCount = authorRowCount + 1;
        }



        ATTUserLogin user = ((ATTUserLogin)Session["Login_User_Detail"]);

        try
        {
            if (LM.Action == "A")
            {
                if (user.MenuList["4,9,1"] == null || user.MenuList["4,9,1"].PAdd == "N")
                {
                    this.lblStatusMessage.Text = Utilities.PreviledgeMsg + " add Library Material.";
                    this.programmaticModalPopup.Show();
                    return;
                }
            }
            else if (LM.Action == "M")
            {
                if (user.MenuList["4,9,1"] == null || user.MenuList["4,9,1"].PEdit == "N")
                {
                    this.lblStatusMessage.Text = Utilities.PreviledgeMsg + " update Library Material.";
                    this.programmaticModalPopup.Show();
                    return;
                }
            }

            Previlege.PrevilegeType pType = Previlege.PrevilegeType.P_ADD;
            string modeName = "";

            if (LM.Action == "A")
            {
                pType    = Previlege.PrevilegeType.P_ADD;
                modeName = "added";
            }
            else if (LM.Action == "M")
            {
                pType    = Previlege.PrevilegeType.P_EDIT;
                modeName = "updated";
            }

            Previlege pobj = new Previlege(user.UserName, "4,9,1", 4, pType);


            Session["LM"] = LM;

            //save details
            //save master detail every time
            if (Session["LibMatID"] == null)
            {
                LM.Action = "A";
            }
            else
            {
                LM.Action      = "M";
                LM.LMaterialID = long.Parse(Session["LibMatID"].ToString());
            }
            long LMID = BLLLibraryMaterial.AddLibraryMaterial(LM, pobj);
            Session["LibMatID"] = LMID;

            if (this.hdnAction.Value == "M")
            {
                if (this.libMatCopyGrd.SelectedIndex > -1)
                {
                    SaveLibraryDetails(LMID, "M", long.Parse(Session["AccessionID"].ToString()));
                    LoadLibraryMaterialCopyGrid(LMID);
                }
                else if (this.libMatCopyGrd.SelectedIndex < 0)
                {
                    if (this.editionTxt.Text != "" && this.pubDateTxt.Text != "" && this.priceTxt.Text != "" && this.isbnTxt.Text != "")
                    {
                        SaveLibraryDetails(LMID, "A", 0);
                        LoadLibraryMaterialCopyGrid(LMID);
                    }
                }
            }
            else if (this.hdnAction.Value != "M")
            {
                if (this.libMatCopyGrd.SelectedIndex > -1)
                {
                    //update the material copy
                    SaveLibraryDetails(LMID, "M", long.Parse(Session["AccessionID"].ToString()));
                    LoadLibraryMaterialCopyGrid(LMID);
                }
                else if (this.libMatCopyGrd.SelectedIndex < 0)
                {
                    //add new material copy
                    SaveLibraryDetails(LMID, "A", 0);
                    LoadLibraryMaterialCopyGrid(LMID);
                }
            }


            this.ClearLibraryMaterialControl();
            this.ClearLMCopyControls();
            this.LoadRegDate();

            this.lblStatusMessage.Text = "Library material " + modeName + " successfully.";
            this.programmaticModalPopup.Show();
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message;
            this.programmaticModalPopup.Show();
            return;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //string hex = ConvertStringToHex("System.Runtime.Seria", Encoding.Unicode);
        //string data = ConvertHexToString(hex, Encoding.Unicode);
        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
        Response.Expires         = -1500;
        Response.CacheControl    = "no-cache";

        if (Session["Login_User_Detail"] == null)
        {
            Response.Redirect("~/MODULES/Login.aspx", true);
        }

        //block if from URL
        ATTUserLogin user = ((ATTUserLogin)Session["Login_User_Detail"]);

        if (user.MenuList.ContainsKey("4,9,1") == true || user.MenuList.ContainsKey("4,10,1") == true)
        {
            if (this.IsPostBack == false)
            {
                this.lnkViewFile.Visible = false;

                this.LoadOrganization();
                this.LoadLibrary();
                this.LoadCategory();
                this.LoadMaterialType();
                this.LoadLanguage();
                this.LoadPublisher();
                this.LoadKeyword();
                this.LoadAuthor();
                this.LoadCurrency();
                this.LoadRegDate();

                Session["LibMatID"] = null;


                this.CreateSessionForLibraryMaterial();

                this.ClearLibraryMaterialControl();

                try
                {
                    ATTLibraryMaterial libraryMat = (ATTLibraryMaterial)Session["LibraryMatToEdit"];
                    if (libraryMat != null)
                    {
                        this.LoadLibraryMaterialToEdit(libraryMat);
                        this.LoadLibraryMaterialCopy(libraryMat);
                        Session["LibraryMatToEdit"] = null;
                        this.hdnAction.Value        = "M";
                        this.LoadValidationSymbol();
                    }

                    this.lnkViewFile.Visible = true;
                }
                catch (Exception)
                {
                }
            }
        }
        else
        {
            Response.Redirect("~/MODULES/Login.aspx", true);
        }
    }
    protected void btnAddAuthor_Click(object sender, EventArgs e)
    {
        if (this.ddlAuthor.SelectedIndex <= 0)
        {
            return;
        }

        ATTLibraryMaterial LM = (ATTLibraryMaterial)Session["LM_LibraryMaterial"];

        GridViewRow row;
        int         rowCount = 0;

        foreach (ATTLibraryMaterialAuthor ath in LM.LstLMAuthor)
        {
            row            = this.grdAuthor.Rows[rowCount];
            ath.HasChecked = ((CheckBox)row.FindControl("chkAuthor")).Checked;

            rowCount = rowCount + 1;
        }

        ATTAuthor author = new ATTAuthor
                           (
            int.Parse(this.ddlAuthor.SelectedValue),
            this.ddlAuthor.SelectedItem.Text
                           );

        ATTLibraryMaterialAuthor LMAuthor = new ATTLibraryMaterialAuthor();

        LMAuthor.OrgID     = int.Parse(this.ddlOrg.SelectedValue);
        LMAuthor.LibraryID = int.Parse(this.ddlLibrary.SelectedValue);
        if (this.hdnAction.Value != "M")
        {
            LMAuthor.LMaterialID = 0;
        }
        LMAuthor.EntryBy = ((ATTUserLogin)Session["Login_User_Detail"]).UserName;
        LMAuthor.EntryOn = DateTime.Now;
        LMAuthor.Action  = "A";

        LMAuthor.Author = author;

        ATTLibraryMaterialAuthor existAuthor = LM.LstLMAuthor.Find
                                               (
            delegate(ATTLibraryMaterialAuthor lma)
        {
            return
            (lma.OrgID == LMAuthor.OrgID &&
             lma.LibraryID == LMAuthor.LibraryID &&
             lma.AuthorID == LMAuthor.AuthorID);
        }
                                               );

        if (existAuthor != null)
        {
            return;
        }

        LM.LstLMAuthor.Add(LMAuthor);

        this.grdAuthor.DataSource = LM.LstLMAuthor;
        this.grdAuthor.DataBind();
    }
    protected void btnAddKeyword_Click(object sender, EventArgs e)
    {
        if (this.ddlKeyword.SelectedIndex <= 0)
        {
            return;
        }

        ATTLibraryMaterial LM = (ATTLibraryMaterial)Session["LM_LibraryMaterial"];

        GridViewRow row;
        int         rowCount = 0;

        foreach (ATTLibraryMaterialKeyword ky in LM.LstLMKeyword)
        {
            row           = this.grdKeyword.Rows[rowCount];
            ky.HasChecked = ((CheckBox)row.FindControl("chkKeyword")).Checked;

            rowCount = rowCount + 1;
        }

        ATTKeyword key = new ATTKeyword
                         (
            int.Parse(this.ddlKeyword.SelectedValue),
            this.ddlKeyword.SelectedItem.Text
                         );

        ATTLibraryMaterialKeyword LMkey = new ATTLibraryMaterialKeyword();

        LMkey.OrgID     = int.Parse(this.ddlOrg.SelectedValue);
        LMkey.LibraryID = int.Parse(this.ddlLibrary.SelectedValue);
        if (this.hdnAction.Value != "M")
        {
            LMkey.LMaterialID = 0;
        }
        LMkey.EntryBy    = ((ATTUserLogin)Session["Login_User_Detail"]).UserName;
        LMkey.EntryOn    = DateTime.Now;
        LMkey.Action     = "A";
        LMkey.HasChecked = false;

        LMkey.Keyword = key;

        ATTLibraryMaterialKeyword existKey = LM.LstLMKeyword.Find
                                             (
            delegate(ATTLibraryMaterialKeyword lmk)
        {
            return
            (lmk.OrgID == LMkey.OrgID &&
             lmk.LibraryID == LMkey.LibraryID &&
             lmk.KeywordID == LMkey.KeywordID);
        }
                                             );

        if (existKey != null)
        {
            return;
        }


        LM.LstLMKeyword.Add(LMkey);

        this.grdKeyword.DataSource = LM.LstLMKeyword;
        this.grdKeyword.DataBind();
    }
 void CreateSessionForLibraryMaterial()
 {
     Session["LM_LibraryMaterial"] = new ATTLibraryMaterial();
 }
        public static long AddLibraryMaterial(ATTLibraryMaterial obj, Previlege pobj)
        {
            string InsertSP;

            OracleParameter[] paramArray;
            if (obj.Action == "A")
            {
                InsertSP       = "SP_ADD_LIBRARY_MATERIAL";
                paramArray     = new OracleParameter[18];
                paramArray[17] = Utilities.GetOraParam(":p_ENTRY_BY", obj.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input);
            }
            else
            {
                InsertSP   = "SP_EDIT_LIBRARY_MATERIAL";
                paramArray = new OracleParameter[17];
            }

            paramArray[0]  = Utilities.GetOraParam(":p_ORG_ID", obj.OrgID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[1]  = Utilities.GetOraParam(":p_LIBRARY_ID", obj.LibraryID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[2]  = Utilities.GetOraParam(":p_L_MATERIAL_ID", obj.LMaterialID, OracleDbType.Decimal, ParameterDirection.InputOutput);
            paramArray[3]  = Utilities.GetOraParam(":p_MT_ID", obj.LibraryMaterialType, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[4]  = Utilities.GetOraParam(":p_CATEGORY_ID", obj.LibraryMaterialCategory, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[5]  = Utilities.GetOraParam(":p_CALL_NO", obj.CallNo, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[6]  = Utilities.GetOraParam(":p_CORPORATE_BODY", obj.CorporateBody, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[7]  = Utilities.GetOraParam(":p_TITLE", obj.Title, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[8]  = Utilities.GetOraParam(":p_SERIES_STATE", obj.SeriesStatement, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[9]  = Utilities.GetOraParam(":p_NOTE", obj.Note, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[10] = Utilities.GetOraParam(":p_BRD_SUBJECT_HEADING", obj.BoardSubjectHeading, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[11] = Utilities.GetOraParam(":p_GEO_DESC", obj.GeoDescription, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[12] = Utilities.GetOraParam(":p_LANG_ID", obj.LanguageID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[13] = Utilities.GetOraParam(":p_PHY_DESC", obj.PhysicalDescription, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[14] = Utilities.GetOraParam(":p_PUBLISHER_ID", obj.PublisherID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[15] = Utilities.GetOraParam(":p_CONTENT_FILE", obj.ContentFile, OracleDbType.Blob, ParameterDirection.Input);
            paramArray[16] = Utilities.GetOraParam(":p_FILE_TYPE", obj.CFileType, OracleDbType.Varchar2, ParameterDirection.Input);

            GetConnection    GetConn = new GetConnection();
            OracleConnection DBConn  = GetConn.GetDbConn(Module.LIS);

            string modeName = "";

            if (obj.Action == "A")
            {
                modeName = "add";
            }
            else if (obj.Action == "M")
            {
                modeName = "update";
            }

            if (Previlege.HasPrevilege(pobj, DBConn) == false)
            {
                throw new ArgumentException(Utilities.PreviledgeMsg + " " + modeName + " Library Material.");
            }

            OracleTransaction Tran = DBConn.BeginTransaction();

            try
            {
                SqlHelper.ExecuteNonQuery(DBConn, CommandType.StoredProcedure, InsertSP, paramArray);
                obj.LMaterialID = long.Parse(paramArray[2].Value.ToString());



                DLLLibraryMaterialKeyword.AddLibraryMaterialKeyword(obj.LstLMKeyword, obj.LMaterialID, Tran);

                DLLLibraryMaterialAuthor.AddLibraryMaterialAuthor(obj.LstLMAuthor, obj.LMaterialID, Tran);



                Tran.Commit();

                return(obj.LMaterialID);
            }
            catch (Exception ex)
            {
                Tran.Rollback();
                throw ex;
            }
            finally
            {
                GetConn.CloseDbConn();
            }
        }
        public static DataTable GetSearchedLibraryMaterialTable(ATTLibraryMaterial criteria, string keywordCollection, string authorCollection)
        {
            string SelectVW = "";

            List <OracleParameter> paramArray = new List <OracleParameter>();

            string columnName = "Org_ID,Library_ID,L_Material_ID,Accession_ID,Title,MT_ID,Category_ID,Call_NO,Corporate_Body,Series_State,Note,Brd_Subject_Heading,Geo_Desc,Phy_Desc,Lang_ID,Publisher_ID,File_Type,Edition,Pub_Date,Reg_Date,Isbn_Issn,Price,Currency_ID,MT_COPY_LOC";

            SelectVW = "  SELECT " + columnName + " FROM VW_LIBRARY_INFO WHERE ORG_ID=" + criteria.OrgID + " AND LIBRARY_ID=" + criteria.LibraryID;

            if (criteria.LibraryMaterialType > 0)
            {
                SelectVW += " AND MT_ID=" + criteria.LibraryMaterialType;
            }

            if (criteria.LibraryMaterialCategory > 0)
            {
                SelectVW += " AND CATEGORY_ID=" + criteria.LibraryMaterialCategory;
            }

            if (criteria.LanguageID > 0)
            {
                SelectVW += " AND LANG_ID=" + criteria.LanguageID;
            }

            if (criteria.PublisherID > 0)
            {
                SelectVW += " AND PUBLISHER_ID=" + criteria.PublisherID;
            }

            if (criteria.CallNo != "")
            {
                SelectVW += " AND UPPER(CALL_NO)=:CALLNO";
                paramArray.Add(Utilities.GetOraParam(":CALLNO", criteria.CallNo.ToUpper(), OracleDbType.Varchar2, ParameterDirection.Input));
            }

            if (keywordCollection != "")
            {
                SelectVW += " AND (ORG_ID,LIBRARY_ID,L_MATERIAL_ID)";
                SelectVW += " IN";
                SelectVW += " (SELECT DISTINCT ORG_ID,LIBRARY_ID,L_MATERIAL_ID FROM VW_LM_KEYWORD WHERE KEYWORD_ID IN (" + keywordCollection + ") AND ORG_ID=" + criteria.OrgID + " AND LIBRARY_ID=" + criteria.LibraryID + ")";
            }

            if (authorCollection != "")
            {
                SelectVW += " AND (ORG_ID,LIBRARY_ID,L_MATERIAL_ID)";
                SelectVW += " IN";
                SelectVW += " (SELECT DISTINCT ORG_ID,LIBRARY_ID,L_MATERIAL_ID FROM VW_LM_AUTHOR WHERE AUTHOR_ID IN (" + authorCollection + ") AND ORG_ID=" + criteria.OrgID + " AND LIBRARY_ID=" + criteria.LibraryID + ")";
            }

            SelectVW += " ORDER BY L_MATERIAL_ID, ACCESSION_ID";

            try
            {
                return(SqlHelper.ExecuteDataset(CommandType.Text, SelectVW, Module.LIS, paramArray.ToArray()).Tables[0]);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static List <ATTLibraryMaterial> GetSearchedLibraryMaterialList(ATTLibraryMaterial criteria, string keyCollection, string authorCollection, string action)
        {
            try
            {
                #region "Commented logic for merging material copy"
                //List<ATTLibraryMaterial> lstLM = new List<ATTLibraryMaterial>();
                //DataTable tblLM = DLLLibraryMaterial.GetSearchedLibraryMaterialTable();

                //int orgID;
                //int libraryID;
                //long lMaterialID;
                //long accessionID;

                //ATTLibraryMaterial tempLib = new ATTLibraryMaterial();

                //foreach (DataRow row in tblLM.Rows)
                //{
                //    ATTLibraryMaterial lib = null;

                //    orgID = int.Parse(row["Org_ID"].ToString());
                //    libraryID = int.Parse(row["Library_ID"].ToString());
                //    lMaterialID = long.Parse(row["L_Material_ID"].ToString());
                //    accessionID = long.Parse(row["Accession_ID"].ToString());

                //    lib = lstLM.Find
                //                    (
                //                        delegate(ATTLibraryMaterial LM)
                //                        {
                //                            return LM.OrgID == orgID &&
                //                                LM.LibraryID == libraryID &&
                //                                LM.LMaterialID == lMaterialID;
                //                        }
                //                    );

                //    if (lib == null)
                //    {
                //        lib = new ATTLibraryMaterial();
                //        lib.OrgID = orgID;
                //        lib.LibraryID = libraryID;
                //        lib.LMaterialID = lMaterialID;

                //        tempLib = lib;

                //        lstLM.Add(tempLib);
                //    }

                //    ATTLibraryMaterialCopy libCopy = null;

                //    libCopy = tempLib.LstLMCopy.Find
                //                                    (
                //                                        delegate(ATTLibraryMaterialCopy copy)
                //                                        {
                //                                            return
                //                                                copy.OrgID == orgID &&
                //                                                copy.LibraryID == libraryID &&
                //                                                copy.LMaterialID == lMaterialID &&
                //                                                copy.AccessionID == accessionID;
                //                                        }
                //                                    );

                //    if (libCopy == null)
                //    {
                //        libCopy = new ATTLibraryMaterialCopy();
                //        libCopy.OrgID = orgID;
                //        libCopy.LibraryID = libraryID;
                //        libCopy.LMaterialID = lMaterialID;
                //        libCopy.AccessionID = accessionID;

                //        tempLib.LstLMCopy.Add(libCopy);
                //    }
                //}
                //return lstLM;

                #endregion

                DataTable tbl = DLLLibraryMaterial.GetSearchedLibraryMaterialTable(criteria, keyCollection, authorCollection);

                List <ATTLibraryMaterial> lstLM = new List <ATTLibraryMaterial>();

                int  orgID;
                int  libraryID;
                long lMaterialID;
                long accessionID;

                ATTLibraryMaterial tempLib = new ATTLibraryMaterial();

                foreach (DataRow row in tbl.Rows)
                {
                    ATTLibraryMaterial lib = null;

                    orgID       = int.Parse(row["Org_ID"].ToString());
                    libraryID   = int.Parse(row["Library_ID"].ToString());
                    lMaterialID = long.Parse(row["L_Material_ID"].ToString());
                    accessionID = long.Parse(row["Accession_ID"].ToString());

                    lib = lstLM.Find
                          (
                        delegate(ATTLibraryMaterial LM)
                    {
                        return(LM.OrgID == orgID &&
                               LM.LibraryID == libraryID &&
                               LM.LMaterialID == lMaterialID);
                    }
                          );

                    if (lib == null)
                    {
                        lib                         = new ATTLibraryMaterial();
                        lib.OrgID                   = orgID;
                        lib.LibraryID               = libraryID;
                        lib.LMaterialID             = lMaterialID;
                        lib.Title                   = row["Title"].ToString();
                        lib.LibraryMaterialType     = int.Parse(row["MT_ID"].ToString());
                        lib.LibraryMaterialCategory = int.Parse(row["Category_ID"].ToString());
                        lib.CallNo                  = row["Call_NO"].ToString();
                        lib.CorporateBody           = row["Corporate_Body"].ToString();
                        lib.SeriesStatement         = row["Series_State"].ToString();
                        lib.Note                    = row["Note"].ToString();
                        lib.BoardSubjectHeading     = row["Brd_Subject_Heading"].ToString();
                        lib.GeoDescription          = row["Geo_Desc"].ToString();
                        lib.PhysicalDescription     = row["Phy_Desc"].ToString();
                        lib.LanguageID              = int.Parse(row["Lang_ID"].ToString());
                        lib.PublisherID             = int.Parse(row["Publisher_ID"].ToString());
                        //if (row["Content_File"] == System.DBNull.Value)
                        //    lib.ContentFile = null;
                        //else
                        //    lib.ContentFile = (byte[])row["Content_File"];
                        lib.CFileType = row["File_Type"].ToString();

                        lib.Action = action;

                        tempLib = lib;

                        lstLM.Add(tempLib);
                    }

                    ATTLibraryMaterialCopy libCopy = null;

                    libCopy = tempLib.LstLMCopy.Find
                              (
                        delegate(ATTLibraryMaterialCopy copy)
                    {
                        return
                        (copy.OrgID == orgID &&
                         copy.LibraryID == libraryID &&
                         copy.LMaterialID == lMaterialID &&
                         copy.AccessionID == accessionID);
                    }
                              );

                    if (libCopy == null)
                    {
                        libCopy = new ATTLibraryMaterialCopy();

                        libCopy.OrgID            = orgID;
                        libCopy.LibraryID        = libraryID;
                        libCopy.LMaterialID      = lMaterialID;
                        libCopy.AccessionID      = accessionID;
                        libCopy.Edition          = row["Edition"].ToString();
                        libCopy.PublicationDate  = row["Pub_Date"].ToString();
                        libCopy.RegistrationDate = (DateTime)row["Reg_Date"];
                        libCopy.IsbnIssnNo       = row["Isbn_Issn"].ToString();
                        libCopy.Price            = double.Parse((row["Price"] == System.DBNull.Value) ? "0" : row["Price"].ToString());
                        libCopy.CurrencyID       = int.Parse(row["Currency_ID"].ToString());
                        libCopy.Location         = row["MT_COPY_LOC"].ToString();
                        libCopy.Action           = action;

                        tempLib.LstLMCopy.Add(libCopy);
                    }
                }

                return(lstLM);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static ObjectValidation Validate(ATTLibraryMaterial obj)
        {
            ObjectValidation OV = new ObjectValidation();

            if (obj.OrgID <= 0)
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Please select Organization.";
                return(OV);
            }

            if (obj.LibraryID <= 0)
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Please select Library.";
                return(OV);
            }

            if (obj.LibraryMaterialCategory <= 0)
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Please select Category.";
                return(OV);
            }

            if (obj.LibraryMaterialType <= 0)
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Please select Type.";
                return(OV);
            }

            if (obj.CallNo == "")
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Call no cannot be blank.";
                return(OV);
            }

            if (obj.Title == "")
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Title cannot be blank.";
                return(OV);
            }

            if (obj.ContentFile != null)
            {
                decimal size = decimal.Parse(obj.ContentFile.Length.ToString());
                size = size / 1024;
                size = size / 1024;
                size = Math.Round(size, 2);

                if (size > 2)
                {
                    OV.IsValid      = false;
                    OV.ErrorMessage = "File size cannot be greater then 2 MB.Currrent file size: " + size.ToString() + " MB";
                    return(OV);
                }
            }

            if (obj.ContentFile != null)
            {
                if (obj.CFileType.ToUpper() != ".TXT" && obj.CFileType.ToUpper() != ".PDF" && obj.CFileType.ToUpper() != ".JPG" && obj.CFileType.ToUpper() != ".JPEG" && obj.CFileType.ToUpper() != ".GIF")
                {
                    OV.IsValid      = false;
                    OV.ErrorMessage = "File must be of (pdf, jpg, jpeg, txt) type.";
                    return(OV);
                }
            }

            if (obj.EntryBy == "")
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Invalid user.";
                return(OV);
            }

            return(OV);
        }