Ejemplo n.º 1
0
        public DecisionInfo GetDecisionByCode(string code, string _userID)
        {
            DecisionInfo         record        = new DecisionInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = DecisionDataLayer.GetInstance().GetDecisionByCode(connection, code, _userID);
                if (record == null)
                {
                    return(null);
                }

                record.Items = new List <ItemInfo>();
                record.Items = QuoteDataLayer.GetInstance().GetQuoteItems(connection, record.QuoteID);

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Decision.ToString();
                documentCriteria.PreferId  = record.QuoteID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Decision.ToString();
                commentCriteria.PreferId  = record.QuoteID.ToString();
                record.ListComment        = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in record.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }

                return(record);
            }
        }
Ejemplo n.º 2
0
        public ActionMessage DeleteMuti(string ids)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete comments
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Acceptance.ToString();
                    string[] IDsarray = ids.Split(',');
                    foreach (string id in IDsarray)
                    {
                        _criteria.PreferId = id;
                        CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);
                    }

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentsByFeature(TableFile.Acceptance.ToString(), ids);



                    //delete records
                    AcceptanceDataLayer.GetInstance().DeleteMuti(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
Ejemplo n.º 3
0
        public ProposalDetailInfo getDetailProposal(int _ID, string _userID)
        {
            ProposalDetailInfo   proposalDetail = new ProposalDetailInfo();
            SqlConnectionFactory sqlConnection  = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                proposalDetail = ProposalDataLayer.GetInstance().getProposalDetail(connection, _ID, _userID);
                if (proposalDetail == null)
                {
                    return(null);
                }
                proposalDetail.ListComment = new List <CommentInfo>();

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName  = TableFile.Proposal.ToString();
                documentCriteria.PreferId   = _ID.ToString();
                proposalDetail.ListDocument = DocumentService.GetInstance().GetDocument(documentCriteria);

                proposalDetail.Items = new List <ItemPropsalInfo>();
                proposalDetail.Items = ProposalDataLayer.GetInstance().GetPropsalItems(connection, _ID);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName  = TableFile.Proposal.ToString();
                commentCriteria.PreferId   = _ID.ToString();
                proposalDetail.ListComment = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in proposalDetail.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }
                return(proposalDetail);
            }
        }
Ejemplo n.º 4
0
        public NegotiationInfo GetNegotiation(int _ID, string _userID)
        {
            NegotiationInfo      record        = new NegotiationInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = NegotiationDataLayer.GetInstance().getNegotiation(connection, _ID, _userID);
                if (record == null)
                {
                    return(null);
                }

                record.Items = QuoteDataLayer.GetInstance().getSelectedItemsQuote(connection,
                                                                                  record.QuoteID);

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Negotiation.ToString();
                documentCriteria.PreferId  = _ID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);
                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Negotiation.ToString();
                commentCriteria.PreferId  = _ID.ToString();
                record.ListComment        = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in record.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }

                return(record);
            }
        }
Ejemplo n.º 5
0
        public ActionMessage DeleteMuti(string ids, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete comments
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Negotiation.ToString();
                    string[] IDsarray = ids.Split(',');
                    foreach (string id in IDsarray)
                    {
                        _criteria.PreferId = id;
                        CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);
                    }

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentsByFeature(TableFile.Negotiation.ToString(), ids);
                    //delete records
                    List <string> quoteID = NegotiationDataLayer.GetInstance().GetQuoteByNegotiationIds(connection, ids);
                    QuoteService.GetInstance().deleteProcess(connection, "Negotiation", String.Join(", ", quoteID.ToArray()), _userID);
                    NegotiationDataLayer.GetInstance().DeleteMuti(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
Ejemplo n.º 6
0
        public AcceptanceInfo GetDetail(int id, string _userID)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
            AcceptanceInfo       record        = new AcceptanceInfo();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = AcceptanceDataLayer.GetInstance().GetDetail(connection, id, _userID);
                if (record == null)
                {
                    return(null);
                }
                record.ListComment = new List <CommentInfo>();

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Acceptance.ToString();
                documentCriteria.PreferId  = id.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                record.Items = new List <DeliveryReceiptItemInfoNew>();
                record.Items = DeliveryReceiptDataLayer.GetInstance().getSelectedItems(connection, record.DeliveryReceiptID, _userID);
                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Acceptance.ToString();
                commentCriteria.PreferId  = id.ToString();
                record.ListComment        = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in record.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }
            }
            return(record);
        }
Ejemplo n.º 7
0
        public ExplanationDetailInfo getDetailExplanation(int _ID, string _userID)
        {
            ExplanationDetailInfo record        = new ExplanationDetailInfo();
            SqlConnectionFactory  sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = ExplanationDataLayer.GetInstance().getExplanationDetail(connection, _ID, _userID);
                if (record == null)
                {
                    return(null);
                }

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Explanation.ToString();
                documentCriteria.PreferId  = _ID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                record.Items = new List <ItemPropsalInfo>();
                record.Items = ProposalDataLayer.GetInstance().GetPropsalItems(connection, record.ProposalID);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Explanation.ToString();
                commentCriteria.PreferId  = _ID.ToString();
                record.ListComment        = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in record.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }
                return(record);
            }
        }
Ejemplo n.º 8
0
        public ActionMessage Delete(int id, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentByFeature(TableFile.BidPlan.ToString(), id);


                    //delete commet
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.BidPlan.ToString();
                    _criteria.PreferId  = id.ToString();
                    CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);

                    //delete record
                    List <string> negotiationIDs = NegotiationDataLayer.GetInstance().GetNegotiationByBidPlanIds(connection, id.ToString());
                    List <string> quoteID        = BidPlanDataLayer.GetInstance().GetQuoteByBidPlanIds(connection, id.ToString());
                    QuoteService.GetInstance().deleteProcess(connection, "BidPlan", String.Join(", ", quoteID.ToArray()), _userID);
                    BidPlanDataLayer.GetInstance().Delete(connection, id);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }
Ejemplo n.º 9
0
        public async Task <ActionMessage> Create(DeliveryReceiptInfo obj, [FromForm] List <IFormFile> files, string _userI, string _userID)
        {
            ActionMessage        ret           = new ActionMessage();
            int                  insetId       = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    insetId = DeliveryReceiptDataLayer.GetInstance().Create(connection, obj, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (insetId > -1)
            {
                ret.id = insetId;
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        if (obj.Items != null)
                        {
                            // insertEmployees(insetId, obj.Employees);
                            foreach (DeliveryReceiptItemInfoNew item in obj.Items)
                            {
                                item.DeliveryReceiptID = insetId;
                                if (item.Amount > 0)
                                {
                                    //input tai san
                                    DeliveryReceiptWithDepartment deliveryReceipt = DeliveryReceiptDataLayer.GetInstance().getItemCreateAna(connection, item.DeliveryReceiptID, _userID);
                                    AnalyzerInfo analyzerInfo = new AnalyzerInfo()
                                    {
                                        AnalyzerAccountantCode = "",
                                        AnalyzerName           = item.ItemName,
                                        AnalyzerType           = 0,

                                        QuoteItemID = item.QuoteItemID,
                                        Description = "",

                                        Amount           = item.Amount,
                                        ItemPrice        = item.ItemPrice,
                                        TotalPrice       = item.TotalPrice,
                                        DepartmentRootID = deliveryReceipt.DepartmentID,
                                        DepartmentID     = deliveryReceipt.DepartmentID,

                                        ContractCode  = deliveryReceipt.ContractCode,
                                        UserIContract = deliveryReceipt.UserIContract,
                                        CustomerID    = deliveryReceipt.CustomerID,
                                        CustomerName  = deliveryReceipt.CustomerName,

                                        ExpirationDate    = DateTime.Now,
                                        DateIn            = obj.DeliveryReceiptDate,
                                        DeliveryReceiptID = item.DeliveryReceiptID,
                                        Serial            = "",
                                    };

                                    int seq      = AnalyzerDataLayer.GetInstance().GetMaxPropCode(connection, analyzerInfo.DateIn.Year);
                                    int insertID = AnalyzerDataLayer.GetInstance().InsertAnalyzer(connection, analyzerInfo, seq, _userI);

                                    string[] _anaNamesSplit = analyzerInfo.AnalyzerName.Split(' ');
                                    string   _anaNameSplit  = "";
                                    for (int i = 0; i < _anaNamesSplit.Count(); i++)
                                    {
                                        if (i == 4)
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            _anaNameSplit += (_anaNamesSplit[i][0]).ToString().ToUpper();
                                        }
                                    }
                                    string anacode = _anaNameSplit + "." + analyzerInfo.DateIn.Year + "." + String.Format("{0:000000}", seq);
                                    AnalyzerDataLayer.GetInstance().UpdateAnalyzer(connection, insertID, anacode);
                                    // end insert
                                    DeliveryReceiptDataLayer.GetInstance().CreateDeliveryReceiptItem(connection, item, _userI);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        if (obj.Employees != null)
                        {
                            foreach (DeliveryReceiptEmployeeInfo item in obj.Employees)
                            {
                                item.DeliveryReceiptID = insetId;
                                DeliveryReceiptDataLayer.GetInstance().CreateDeliveryReceiptItemUser(connection, item, _userI);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.DeliveryReceipt.ToString();
                    documentInfo.PreferId  = insetId.ToString();
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.DeliveryReceipt.ToString(), insetId.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
                }
                ret.isSuccess = true;
            }
            else
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "lỗi thêm phiếu nghiệm thu";
                ret.err.msgString = "lỗi thêm phiếu nghiệm thu";
            }
            return(ret);
        }
Ejemplo n.º 10
0
        public async Task <ActionMessage> Update(DeliveryReceiptInfo obj, [FromForm] List <IFormFile> files, string _userI)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    DeliveryReceiptDataLayer.GetInstance().Update(connection, obj, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }


            /*  using (SqlConnection connection = sqlConnection.GetConnection())
             * {
             *    try
             *    {
             *        EditEmployees(obj.DeliveryReceiptID, obj.Employees);
             *        foreach (DeliveryReceiptItemInfoNew item in obj.Items)
             *        {
             *            DeliveryReceiptDataLayer.GetInstance().UpdateDeliveryReceiptItem(connection, item, _userI);
             *        }
             *    }
             *    catch (Exception ex)
             *    {
             *        throw ex;
             *    }
             * }*/

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    DeliveryReceiptDataLayer.GetInstance().DeleteDeliveryReceiptItemUser(connection, obj.DeliveryReceiptID, _userI);


                    if (obj.Employees != null)
                    {
                        foreach (DeliveryReceiptEmployeeInfo item in obj.Employees)
                        {
                            item.DeliveryReceiptID = obj.DeliveryReceiptID;
                            DeliveryReceiptDataLayer.GetInstance().CreateDeliveryReceiptItemUser(connection, item, _userI);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            DocumentService.GetInstance().DeleteDocumentsNotExitsInList(obj.ListDocument, TableFile.DeliveryReceipt.ToString(), obj.DeliveryReceiptID);
            foreach (var item in files)
            {
                DocumentInfo documentInfo = new DocumentInfo();
                documentInfo.TableName = TableFile.DeliveryReceipt.ToString();
                documentInfo.PreferId  = obj.DeliveryReceiptID.ToString();
                documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                documentInfo.FileName  = item.FileName;
                documentInfo.Length    = item.Length.ToString();
                documentInfo.Type      = item.ContentType;
                ret = await FilesHelpers.UploadFile(TableFile.DeliveryReceipt.ToString(), obj.DeliveryReceiptID.ToString(), item, documentInfo.Link);

                DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
            }
            ret.isSuccess = true;


            return(ret);
        }
Ejemplo n.º 11
0
        public async Task <ActionMessage> CreateExplanation2(ExplanationInfo _Explanation, string _userI, [FromForm] List <IFormFile> files)
        {
            ActionMessage        ret           = new ActionMessage();
            int                  insetId       = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();



            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    UserLogInfo info = new UserLogInfo();
                    info.Action      = "Insert";
                    info.Description = "ngày : " + _Explanation.InTime + " code : GTMS-" + _Explanation.ProposalCode
                                       + " trạng thái : " + _Explanation.Status;
                    info.Feature  = TableFile.Proposal.ToString();
                    info.Time     = DateTime.Now;
                    info.UserName = _userI;
                    info.UserID   = 1;
                    UserService.GetInstance().TrackUserAction(info);
                    insetId = ExplanationDataLayer.GetInstance().InsertExplanation(connection, _Explanation, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (insetId > -1)
            {
                ret.id = insetId;
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        foreach (ItemPropsalInfo item in _Explanation.Items)
                        {
                            ProposalDataLayer.GetInstance().UpdateItemExplanation(connection, item, _userI);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.Explanation.ToString();
                    documentInfo.PreferId  = insetId.ToString();
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    await FilesHelpers.UploadFile(TableFile.Explanation.ToString(), insetId.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
                }
                ret.isSuccess = true;
            }
            else
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "lỗi thêm phiếu giải trình";
                ret.err.msgString = "lỗi thêm phiếu giải trình";
            }
            return(ret);
        }
Ejemplo n.º 12
0
        public ActionMessage DeleteProposals(string ids, string user, string _userID)
        {
            ActionMessage ret  = new ActionMessage();
            UserLogInfo   info = new UserLogInfo();

            info.Action      = "Delete ";
            info.Description = " ids: " + ids;
            info.Feature     = TableFile.Proposal.ToString();
            info.Time        = DateTime.Now;
            info.UserName    = user;
            info.UserID      = 1;
            UserService.GetInstance().TrackUserAction(info);
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete Items Table
                    List <ItemPropsalInfo> currentItems = ProposalDataLayer.GetInstance().GetPropsalItemsByIds(connection, ids);
                    if (currentItems.Count > 0)
                    {
                        string autoIds = "";
                        foreach (var item in currentItems)
                        {
                            autoIds = autoIds + item.AutoID + ',';
                        }
                        autoIds = autoIds.Remove(autoIds.Length - 1);
                        ProposalDataLayer.GetInstance().DeleteProposalItems(connection, autoIds);
                    }

                    //delete comments
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Proposal.ToString();
                    string[] IDsarray = ids.Split(',');
                    foreach (string id in IDsarray)
                    {
                        _criteria.PreferId = id;
                        CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);
                    }

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentsByFeature(TableFile.Proposal.ToString(), ids);
                    //delete records

                    /*  //deleteRelatedProsal
                     * var quoteIds = QuoteDataLayer.GetInstance().GetQuotesByProposalId(connection, ids);
                     *
                     * QuoteService.DeleteMuti(String.Join(", ", quoteIds.ToArray()));*/

                    var surveyIds = SurveyDataLayer.GetInstance().GetSurveyByProposalId(connection, ids);

                    if (surveyIds != null && surveyIds.Count > 0)
                    {
                        SurveyDataLayer.GetInstance().DeleteMuti(connection, String.Join(", ", surveyIds.ToArray()));
                    }

                    var explanationServiceIds = ExplanationDataLayer.GetInstance().GetExplanationsByProposalId(connection, ids, _userID);
                    if (explanationServiceIds != null && explanationServiceIds.Count > 0)
                    {
                        ExplanationDataLayer.GetInstance().DeleteMuti(connection, String.Join(", ", explanationServiceIds.ToArray()));
                    }


                    ProposalDataLayer.GetInstance().DeleteProposals(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
Ejemplo n.º 13
0
        public ActionMessage DeleteProposal(int id, string user, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    ProposalDetailInfo temp = ProposalService.GetInstance().getDetailProposal(id, "");

                    UserLogInfo info = new UserLogInfo();
                    info.Action = "Delete ";

                    if (temp != null)
                    {
                        info.Description = "code : " + temp.ProposalCode + " id : " + id;
                    }
                    else
                    {
                        info.Description = " id : " + id;
                    }
                    info.Feature  = TableFile.Proposal.ToString();
                    info.Time     = DateTime.Now;
                    info.UserName = user;
                    info.UserID   = 1;
                    UserService.GetInstance().TrackUserAction(info);

                    //delete Items Table
                    List <ItemPropsalInfo> currentItems = ProposalDataLayer.GetInstance().GetPropsalItems(connection, id);
                    if (currentItems.Count > 0)
                    {
                        string autoIds = "";
                        foreach (var item in currentItems)
                        {
                            autoIds = autoIds + item.AutoID + ',';
                        }
                        autoIds = autoIds.Remove(autoIds.Length - 1);
                        ProposalDataLayer.GetInstance().DeleteProposalItems(connection, autoIds);
                    }


                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Proposal.ToString();
                    _criteria.PreferId  = id.ToString();
                    CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentByFeature(TableFile.Proposal.ToString(), id);

                    //deleteRelatedProsal
                    //             ..   var quoteIds = QuoteDataLayer.GetInstance().GetQuotesByProposalId(connection,id.ToString());
                    // if(quoteIds.Count > 0)
                    //                  QuoteService.DeleteMuti(String.Join(", ", quoteIds.ToArray()));


                    var surveyIds = SurveyDataLayer.GetInstance().GetSurveyByProposalId(connection, id.ToString());


                    if (surveyIds.Count > 0)
                    {
                        SurveyDataLayer.GetInstance().DeleteMuti(connection, String.Join(", ", surveyIds.ToArray()));
                    }

                    var explanationServiceIds = ExplanationDataLayer.GetInstance().GetExplanationsByProposalId(connection, id.ToString(), _userID);

                    if (explanationServiceIds.Count > 0)
                    {
                        ExplanationDataLayer.GetInstance().DeleteMuti(connection, String.Join(", ", explanationServiceIds.ToArray()));
                    }


                    //delete record
                    ProposalDataLayer.GetInstance().DeleteProposal(connection, id);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }