Exemple #1
0
        public bool addDocument(string sFileName, string sContentType, byte[] readByteFile, int docSendID, int iParentDocID, string userForwardIDs = "", string docChkLst = "")
        {
            SqlDataAccess objConnection = new SqlDataAccess(clsConstant.DBCONSTRING);

            try
            {
                if (objConnection.Connection.State == ConnectionState.Closed)
                {
                    objConnection.Connection.Open();
                }

                objConnection.BeginTransaction();

                if (docSendID != 0 && iParentDocID != 0)
                {
                    if (sFileName != string.Empty && sContentType != string.Empty && readByteFile != null)
                    {
                        //Insert New File
                        SqlParameter[] param = new SqlParameter[] { new SqlParameter("@filename", sFileName),
                                                                    new SqlParameter("@contenttype", sContentType),
                                                                    new SqlParameter("@attachFile", readByteFile),
                                                                    new SqlParameter("@iDocSendID", docSendID),
                                                                    new SqlParameter("@iPDocID", iParentDocID),
                                                                    new SqlParameter("@iForwardUsers", userForwardIDs), // Use file name as variable for storing Forward ID's
                                                                    new SqlParameter("@iDocSendFid", docChkLst) };

                        objConnection.ExecuteNonQuery(clsConstant.SP_INSERT_DOC_SEND_FILE, CommandType.StoredProcedure, param);
                    }

                    else if ((sFileName == string.Empty && sContentType == string.Empty && readByteFile == null))
                    {
                        //Update "Forward" Details with null values
                        //Insert New File
                        SqlParameter[] param = new SqlParameter[] { new SqlParameter("@iDocSendID", docSendID),
                                                                    new SqlParameter("@iPDocID", iParentDocID),
                                                                    new SqlParameter("@iForwardUsers", userForwardIDs), // Use file name as variable for storing Forward ID's
                                                                    new SqlParameter("@iDocSendFid", docChkLst) };

                        objConnection.ExecuteNonQuery(clsConstant.SP_INSERT_DOC_SEND_FILE, CommandType.StoredProcedure, param);
                    }
                }
                else // GO FOR REPLYALL
                {
                    if (sFileName != string.Empty && sContentType != string.Empty && readByteFile != null)
                    {
                        //Insert New File
                        SqlParameter[] param = new SqlParameter[] { new SqlParameter("@filename", sFileName),
                                                                    new SqlParameter("@contenttype", sContentType),
                                                                    new SqlParameter("@attachFile", readByteFile),
                                                                    new SqlParameter("@iDocSendID", docSendID),
                                                                    new SqlParameter("@iPDocID", iParentDocID),
                                                                    new SqlParameter("@iForwardUsers", userForwardIDs), // Use file name as variable for storing Forward ID's
                                                                    new SqlParameter("@iDocSendFid", docChkLst) };
                        // STORE THE DOCUMENT ID
                        objConnection.ExecuteNonQuery(clsConstant.SP_INSERT_DOC_SEND_FILE, CommandType.StoredProcedure, param);
                    }
                    else if ((sFileName == string.Empty && sContentType == string.Empty && readByteFile == null)) // Forward Document Mapping

                    /*
                     * Insert document in database against a empty message forwarded, with previous document send
                     */
                    {
                        SqlParameter[] param = new SqlParameter[] { new SqlParameter("@iDocSendID", docSendID),
                                                                    new SqlParameter("@iPDocID", iParentDocID),
                                                                    new SqlParameter("@iForwardUsers", userForwardIDs), // Use file name as variable for storing Forward ID's
                                                                    new SqlParameter("@iDocSendFid", docChkLst) };

                        objConnection.ExecuteNonQuery(clsConstant.SP_INSERT_DOC_SEND_FILE, CommandType.StoredProcedure, param);
                    }

                    //// UPLOAD OLD Way THE ATTACHEMENT

                    //if (sFileName != string.Empty && sContentType != string.Empty && readByteFile != null)
                    //{
                    //    //Insert New File
                    //    SqlParameter[] param = new SqlParameter[] { new SqlParameter("@filename", sFileName),
                    //                             new SqlParameter("@contenttype", sContentType),
                    //                             new SqlParameter("@attachFile", readByteFile),
                    //                             new SqlParameter("@iDocSendID", docSendID)
                    //                             };

                    //    objConnection.ExecuteNonQuery(clsConstant.SP_INSERT_DOC_SEND_FILE, CommandType.StoredProcedure, param);
                    //}
                    //else if ((sFileName == string.Empty && sContentType == string.Empty && readByteFile == null))
                    //{
                    //    //Update "Forward" Details with null values
                    //    //Insert New File
                    //    SqlParameter[] param = new SqlParameter[] { new SqlParameter("@iDocSendID", docSendID),
                    //                             };

                    //    objConnection.ExecuteNonQuery(clsConstant.SP_INSERT_DOC_SEND_FILE, CommandType.StoredProcedure, param);

                    //}
                }

                objConnection.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public int saveALLCommentMDB(string MCID, string iDocDettailID, string cType, string sComment, string docNm, DateTime dueDt, int uID = -1, string ToUsers = "", string TaorLoan = "", string CCUsers = "")         // mcid added on 27 dec
        {
            try
            {
                if (objConnection.Connection.State == ConnectionState.Closed)
                {
                    objConnection.Connection.Open();
                }
                ToUsers = ToUsers.Replace("," + uID, "");
                objConnection.BeginTransaction();

                #region SAVE THE NEW DOCUMENT


                SqlParameter[] newParam = new SqlParameter[] {
                    new SqlParameter("@userId", uID),
                    new SqlParameter("@messageDetails", sComment),
                    new SqlParameter("@action", "A"),                                         // reply All
                    new SqlParameter("@docSendID", iDocDettailID),                            // SEND THE DOCUMENT DETAILS ID AND FIND THE PARENT FOR THE SAME
                    new SqlParameter("@docName ", docNm), new SqlParameter("@dueDate", dueDt), new SqlParameter("@mcid", MCID)
                };

                int getId = int.Parse(objConnection.ExecuteScalarQuery("sp_insertSendNewDocumentmdb", CommandType.StoredProcedure, newParam).ToString());
                #endregion

                #region SAVE ALL Users

                if (getId != -1)
                {
                    int defaultval  = 0;                    // CC
                    int defaultval1 = 1;                    // TO
                    // CHECK FOR THE TO USERS
                    if (ToUsers != "")
                    {
                        SqlParameter[] pAllUsers = new SqlParameter[] {
                            new SqlParameter("@iDocID", getId),
                            new SqlParameter("@bToOrCC", defaultval1),
                            new SqlParameter("@vsUsrString", ToUsers),
                            new SqlParameter("@cTAStatus", TaorLoan),
                            new SqlParameter("@action", "A")       // REPLY ALL
                        };                                         //, new SqlParameter("@bIsReply", defaultval) };// For To 1
                        objConnection.ExecuteNonQuery("sp_insertDocSendDetailsMDB", CommandType.StoredProcedure, pAllUsers);
                    }

                    //CHECK FOR CC USERS
                    if (CCUsers != "")
                    {
                        SqlParameter[] pCcUsers = new SqlParameter[] {
                            new SqlParameter("@iDocID", getId),
                            new SqlParameter("@bToOrCC", defaultval),
                            new SqlParameter("@vsUsrString", CCUsers),
                            new SqlParameter("@cTAStatus", TaorLoan),
                            new SqlParameter("@action", "A")       // REPLY ALL
                        };                                         //, new SqlParameter("@bIsReply", defaultval) };// For To 1
                        objConnection.ExecuteNonQuery("sp_insertDocSendDetailsmdb", CommandType.StoredProcedure, pCcUsers);
                    }
                }
                else
                {
                    objConnection.RollbackTransaction();
                    return(-1);
                }

                #endregion
                objConnection.CommitTransaction();

                return(getId);
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }