public void SaveDocument()
    {
        try
        {
            ATTDocument Doc = new ATTDocument();
            Doc.OrgID = int.Parse(drpOrganisation_rqd.SelectedValue);

            if (this.drpOrganisation_rqd.SelectedIndex > 0)
            {
                Doc.UnitID = int.Parse(drpUnit_rqd.SelectedValue);
            }

            Doc.DocFlowType    = int.Parse(drpFlowType_rqd.SelectedValue);
            Doc.DocumentName   = txtDocName_rqd.Text;
            Doc.DocCategory    = int.Parse(drpDocCategory_rqd.SelectedValue);
            Doc.DocDescription = txtDocDesc.Text;

            ObjectValidation OV = BLLDocument.ValidateDocument(Doc);

            if (OV.IsValid == false)
            {
                this.lblStatus.Text = OV.ErrorMessage;
                return;
            }

            if (Session["LstDocAttachment"] != null)
            {
                Doc.LstDocAttachment = (List <ATTDocumentAttachment>)Session["LstDocAttachment"];
            }

            if (Session["LstDocProcess"] != null)
            {
                Doc.LstDocProcess = (List <ATTDocumentProcess>)Session["LstDocProcess"];
            }

            if (BLLDocument.SaveDocument(Doc))
            {
                this.lblStatus.Text = " Document Added Successfully !!!! ";

                this.gvFiles.DataSource = null;
                this.gvFiles.DataBind();

                this.grdDocProcess.DataSource = null;
                this.grdDocProcess.DataBind();

                Session["LstDocAttachment"] = null;
                Session["LstDocProcess"]    = null;

                ScriptManager.RegisterStartupScript(this, this.GetType(), "ClearForm", "javascript:clearForm();", true);

                drpUnit_rqd.Enabled = false;
            }
        }
        catch (Exception ex)
        {
            lblStatus.Text = ex.Message;
        }
    }
 public static bool UpdateDocument(ATTDocument objDoc)
 {
     try
     {
         DLLDocument.UpdateDocument(objDoc);
         return true;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        public static bool SaveDocument(ATTDocument objDoc)
        {
            string SaveSQL            = "SP_ADD_Document";
            int    CountDocAttachment = objDoc.LstDocAttachment.Count;
            int    CountDocProcess    = objDoc.LstDocProcess.Count;
            int    DocSeq             = 0;

            OracleParameter[] paramArray = new OracleParameter[7];
            paramArray[0] = Utilities.GetOraParam(":p_ORG_ID", objDoc.OrgID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[1] = Utilities.GetOraParam(":p_UNIT_ID", objDoc.UnitID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[2] = Utilities.GetOraParam(":p_DOC_ID", null, OracleDbType.Int64, ParameterDirection.Output);
            paramArray[3] = Utilities.GetOraParam(":p_DOCUMENT_NAME", objDoc.DocumentName, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[4] = Utilities.GetOraParam(":p_DOCUMENT_DESC", objDoc.DocDescription, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[5] = Utilities.GetOraParam(":p_FILE_CAT_ID", objDoc.DocCategory, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[6] = Utilities.GetOraParam(":p_DOCUMENT_FLOW_ID", objDoc.DocFlowType, OracleDbType.Int64, ParameterDirection.Input);

            GetConnection     GetConn = new GetConnection();
            OracleConnection  DBConn  = GetConn.GetDbConn(Module.OAS);
            OracleTransaction Tran    = DBConn.BeginTransaction();

            try
            {
                //SqlHelper.ExecuteNonQuery(DBConn, CommandType.StoredProcedure,SaveSQL, paramArray);
                SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, SaveSQL, paramArray);
                objDoc.DocID = int.Parse(paramArray[2].Value.ToString());

                if (CountDocProcess > 0)
                {
                    DocSeq = DLLDocumentProcess.SaveDocProcess(objDoc.OrgID, objDoc.UnitID, objDoc.DocID, objDoc.LstDocProcess, Tran);
                }

                if (CountDocAttachment > 0)
                {
                    DLLDocumentAttachment.SaveDocAttachment(objDoc.OrgID, objDoc.UnitID, objDoc.DocID, objDoc.LstDocAttachment, DocSeq, Tran);
                }

                Tran.Commit();

                return(true);
            }
            catch (Exception ex)
            {
                Tran.Rollback();
                throw(ex);
            }
        }
        public static List<ATTDocument> GetDocumentNameList(int? docID, int? unitID, int? orgID)
        {
            List<ATTDocument> LstDocumentName = new List<ATTDocument>();

            foreach (DataRow row in DLLDocument.GetDocumentNameListTable(docID, unitID, orgID).Rows)
            {
                ATTDocument objDocName = new ATTDocument(
                                                            int.Parse(row["UNIT_ID"].ToString()),
                                                            int.Parse(row["DOC_ID"].ToString()),
                                                            row["DOC_NAME"].ToString()
                                                        );

                LstDocumentName.Add(objDocName);
            }

            return LstDocumentName;
        }
        public static List<ATTDocument> SearchDocumentList(int? orgID, int? unitID, int? docID, string docName,string status)
        {
            List<ATTDocument> LstDocSearch = new List<ATTDocument>();
          
            DataTable tblDoc = new DataTable();
            //tblDoc = DLLDocument.SearchDocumentListTable(orgID, unitID, docID, docName, status, 0);
            tblDoc = DLLDocument.SearchDocumentListTable(orgID, unitID, docID, docName, status);

            DataTable tblDocAttach = new DataTable();
            //tblDocAttach = DLLDocument.SearchDocumentListTable(orgID, unitID, docID, docName, status, 1);
            tblDocAttach = BLLDocumentAttachment.SearchDocumentListTable(orgID, unitID, docID, docName, status);

            DataTable tblDocProcess = new DataTable();
            //tblDocProcess = DLLDocument.SearchDocumentListTable(orgID, unitID, docID, docName, status, 2);
            tblDocProcess = BLLDocumentProcess.SearchDocumentListTable(orgID, unitID, docID, docName, status);

            foreach (DataRow row in tblDoc.Rows)
            {
                ATTDocument objDocName = new ATTDocument(   int.Parse(row["Org_id"].ToString()),
                                                            int.Parse(row["UNIT_ID"].ToString()),
                                                            int.Parse(row["DOC_ID"].ToString()),
                                                            row["DOC_NAME"].ToString(),
                                                            row["DESCRIPTION"].ToString(),
                                                            int.Parse(row["FLOW_ID"].ToString()),
                                                            row["DOC_FLOW_NAME"].ToString(),
                                                            int.Parse(row["CAT_ID"].ToString()),
                                                            row["CATEGORY_NAME"].ToString()
                                                        );

                if (tblDocAttach.Rows.Count > 0)
                {
                    objDocName.LstDocAttachment = SetDocAttachment(tblDocAttach, int.Parse(row["Org_id"].ToString()), int.Parse(row["UNIT_ID"].ToString())
                                                                   , int.Parse(row["DOC_ID"].ToString()));
                }

                if (tblDocProcess.Rows.Count > 0)
                {
                    objDocName.LstDocProcess = SetDocProcess(tblDocProcess, int.Parse(row["Org_id"].ToString()), int.Parse(row["UNIT_ID"].ToString())
                                                            ,int.Parse(row["DOC_ID"].ToString()));
                }

                LstDocSearch.Add(objDocName);
            }
            return LstDocSearch;
        }
    protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            this.drpDocName.Items.Clear();

            if (this.drpUnit.SelectedIndex > 0)
            {
                List <ATTDocument> lstDocument = (List <ATTDocument>)Session["DocSearchDocNameList"];

                ATTDocument objDocName = new ATTDocument();

                objDocName.LstDocName = lstDocument.FindAll(
                    delegate(ATTDocument DocName)
                {
                    return(DocName.UnitID == int.Parse(this.drpUnit.SelectedValue));
                }

                    );

                this.drpDocName.DataSource     = objDocName.LstDocName;
                this.drpDocName.DataTextField  = "DocumentName";
                this.drpDocName.DataValueField = "DocID";
                this.drpDocName.DataBind();

                ListItem a = new ListItem();
                a.Selected = true;
                a.Text     = "Select Unit";
                a.Value    = "0";
                drpDocName.Items.Insert(0, a);

                drpDocName.Enabled = true;
            }
            else
            {
                drpDocName.Enabled = false;
            }
        }
        catch (Exception ex)
        {
            lblStatus.Text = ex.Message;
        }
    }
        public static ObjectValidation ValidateDocument(ATTDocument objDoc)
        {
            ObjectValidation OV = new ObjectValidation();

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

            if (objDoc.UnitID <= 0)
            {
                OV.IsValid = false;
                OV.ErrorMessage = "Please select Unit.";
                return OV;
            }

            if (objDoc.DocFlowType <= 0)
            {
                OV.IsValid = false;
                OV.ErrorMessage = "Please select Document Flow Type.";
                return OV;
            }

            if (objDoc.DocumentName == "")
            {
                OV.IsValid = false;
                OV.ErrorMessage = "Please Enter Document Name.";
                return OV;
            }

            if (objDoc.DocCategory <= 0)
            {
                OV.IsValid = false;
                OV.ErrorMessage = "Please select Document Category.";
                return OV;
            }

            return OV;
        }