예제 #1
0
        public ListResponeMessage <DecisionInfo> GetListWithCondition(
            string decisionCode = "",
            string quoteCode    = "", int customerID    = 0,
            DateTime?fromDate   = null, DateTime?toDate = null, int pageSize = 10, int pageIndex = 0, string _userID = "")
        {
            ListResponeMessage <DecisionInfo> ret = new ListResponeMessage <DecisionInfo>();

            try
            {
                DecisionSeachCriteria _criteria = new DecisionSeachCriteria();
                _criteria.DecisionCode = decisionCode;
                _criteria.QuoteCode    = quoteCode;
                _criteria.CustomerID   = customerID;
                _criteria.FromDate     = fromDate;
                _criteria.ToDate       = toDate;
                _criteria.pageSize     = pageSize;
                _criteria.pageIndex    = pageIndex;
                ret.isSuccess          = true;
                ret.data         = DecisionService.GetInstance().getAllDecision(pageSize, pageIndex, _criteria, _userID);
                ret.totalRecords = DecisionService.GetInstance().getTotalRecords(_criteria, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "005";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
예제 #2
0
        public SingleResponeMessage <DecisionInfo> Get(int id, string _userID)
        {
            SingleResponeMessage <DecisionInfo> ret = new SingleResponeMessage <DecisionInfo>();

            try
            {
                DecisionInfo item = DecisionService.GetInstance().GetDecision(id, _userID);
                if (item == null)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "001";
                    ret.err.msgString = "no Decision found";
                    return(ret);
                }
                ret.item      = item;
                ret.isSuccess = true;
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
예제 #3
0
        public async Task <ActionMessage> Put(int id, [FromForm] DecisionInfo _Decision, [FromForm] List <IFormFile> files, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = DecisionService.GetInstance().editDecision(id, _Decision, GetUserId(), _userID);
                //update list file
                DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_Decision.ListDocument, TableFile.Decision.ToString(), id);
                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.Decision.ToString();
                    documentInfo.PreferId  = id.ToString();
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.Decision.ToString(), _Decision.DecisionID.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
예제 #4
0
        public async Task <ActionMessage> PostwithAttFile([FromForm] DecisionInfo DecisionObj, [FromForm] List <IFormFile> files)
        {
            ActionMessage ret     = new ActionMessage();
            int           insetId = -1;

            try
            {
                insetId       = DecisionService.GetInstance().createDecision2(DecisionObj, GetUserId());
                ret.isSuccess = true;
                if (insetId > -1)
                {
                    ret.id = insetId;
                    foreach (var item in files)
                    {
                        DocumentInfo documentInfo = new DocumentInfo();
                        documentInfo.TableName = TableFile.Decision.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.Decision.ToString(), insetId.ToString(), item, documentInfo.Link);

                        DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                    }
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
예제 #5
0
        public SingleResponeMessage <DecisionInfo> GetByCode(string code, string _userID)
        {
            SingleResponeMessage <DecisionInfo> ret = new SingleResponeMessage <DecisionInfo>();

            ret.isSuccess = true;
            ret.item      = DecisionService.GetInstance().GetDecisionByCode(code, _userID);
            return(ret);
        }
예제 #6
0
    private static void LoadDecisions()
    {
        _decisionScene = DecisionService.GetInstance().LoadDecisionScene();

        var count = _decisionScene.decisions[_currentDecision].options.Count;

        var dvs = DecisionViewService.GetInstance();

        _decisionName  = dvs.GetDecisionName(count);
        _optionButtons = dvs.GetButtonsName(count);
    }
예제 #7
0
        public ActionMessage Post([FromBody] DecisionInfo _decision, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = DecisionService.GetInstance().createDecision(_decision, GetUserId(), _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
예제 #8
0
        public ActionMessage DeleteAll(string decisionIDs, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = DecisionService.GetInstance().DeleteMuti(decisionIDs, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
예제 #9
0
        public ListResponeMessage <string> GetListNegotiationByCode(string code = "", string _userID = "")
        {
            ListResponeMessage <string> ret = new ListResponeMessage <string>();

            try
            {
                ret.isSuccess = true;
                ret.data      = DecisionService.GetInstance().GetListDecisionByCode(code, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
예제 #10
0
        public static MemoryStream GetTemplate(int id, string path, out string code, string _userID)
        {
            double Totalcost    = 0;
            var    memoryStream = new MemoryStream();

            DecisionInfo item = DecisionService.GetInstance().GetDecision(id, _userID);

            QuoteRelation relation = ProposalService.GetInstance().getQuoteRelation(item.QuoteID);

            item.AuditCode   = relation.AuditCode;
            item.AuditTime   = relation.AuditTime;
            item.BidPlanCode = relation.BidPlanCode;
            item.BidPlanTime = relation.BidPlanTime;

            item.NegotiationCode = relation.NegotiationCode;
            item.NegotiationTime = relation.NegotiationTime;

            using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
                fileStream.CopyTo(memoryStream);
            code = "";//item.ProposalCode;
            using (var document = WordprocessingDocument.Open(memoryStream, true))
            {
                document.ChangeDocumentType(WordprocessingDocumentType.Document); // change from template to document
                DateTime date = DateTime.Now;

                var body  = document.MainDocumentPart.Document.Body;
                var paras = body.Elements <Paragraph>();
                foreach (ItemInfo record in item.Items)
                {
                    Totalcost += record.ItemPrice * record.Amount;
                }

                if (item.IsVAT)
                {
                    Totalcost = Totalcost * (item.VATNumber + 100) / 100;
                }

                Table tableData = CreateTable(item, Totalcost);

                string dateInStr = "";
                dateInStr = "ngày " + item.DateIn.Day + " tháng " + item.DateIn.Month + " năm " + item.DateIn.Year;

                string audittimeStr       = "ngày " + item.AuditTime.Day + "/" + item.AuditTime.Month + "/" + item.AuditTime.Year;
                string bidplantimeStr     = "ngày " + item.BidPlanTime.Day + "/" + item.BidPlanTime.Month + "/" + item.BidPlanTime.Year;
                string negotiationtimeStr = "ngày " + item.NegotiationTime.Day + "/" + item.NegotiationTime.Month + "/" + item.NegotiationTime.Year;

                string decisionCodeStr = "";
                if (item.DecisionCode != null && item.DecisionCode != "")
                {
                    decisionCodeStr = item.DecisionCode + "/QĐ-TMHH";
                }
                else
                {
                    decisionCodeStr = "...../QĐ-TMHH";
                }


                var newType = "Về việc chọn đơn vị cung cấp hàng hóa ";
                if (item.BidMethod != 1)
                {
                    newType += "theo hình thức " + HardData.bidMethod[item.BidMethod - 1];
                }
                foreach (var text in body.Descendants <Text>())
                {
                    text.Text = text.Text.Replace("#", "");
                    text.Text = text.Text.Replace("auditcode", WordUtils.checkNull(item.AuditCode));
                    text.Text = text.Text.Replace("bidplancode", WordUtils.checkNull(item.BidPlanCode));
                    text.Text = text.Text.Replace("negotiationcode", WordUtils.checkNull(item.NegotiationCode));
                    text.Text = text.Text.Replace("audittime", audittimeStr);
                    text.Text = text.Text.Replace("bidplantime", bidplantimeStr);
                    text.Text = text.Text.Replace("negotiationtime", negotiationtimeStr);
                    text.Text = text.Text.Replace("newtype", newType);
                    text.Text = text.Text.Replace("datein", WordUtils.checkNull(dateInStr));
                    text.Text = text.Text.Replace("newtype", WordUtils.checkNull(dateInStr));
                    text.Text = text.Text.Replace("costnumber", string.Format("{0:0,0}", Totalcost).Replace(",", "."));
                    text.Text = text.Text.Replace("coststring", WordUtils.checkNull(Utils.NumberToTextVN((decimal)Totalcost)));
                    text.Text = text.Text.Replace("capname", WordUtils.checkNull(item.CapitalName));
                    text.Text = text.Text.Replace("bidtype", item.BidType);
                    text.Text = text.Text.Replace("bidexpired", item.BidExpirated + " " + item.BidExpiratedUnit);
                    text.Text = text.Text.Replace("customername", WordUtils.checkNull(item.CustomerName));
                    text.Text = text.Text.Replace("address", WordUtils.checkNull(item.Address));
                    text.Text = text.Text.Replace("departmentNames", WordUtils.checkNull(item.DepartmentNames));
                    text.Text = text.Text.Replace("vatnumber", WordUtils.checkNull(item.VATNumber.ToString()));
                    //   text.Text = text.Text.Replace("currentyear", );
                    text.Text = text.Text.Replace("bidmethod", HardData.bidMethod[item.BidMethod - 1]);
                    text.Text = text.Text.Replace("decisionCode", " " + WordUtils.checkNull(decisionCodeStr));
                    if (text.Text == "table")
                    {
                        DocumentFormat.OpenXml.OpenXmlElement textP1 = text.Parent;
                        DocumentFormat.OpenXml.OpenXmlElement textP2 = textP1.Parent;
                        body.InsertAfter(tableData, textP2);
                        textP1.Remove();
                    }
                }

                document.Save();
                document.Close();
            }
            return(memoryStream);
        }