예제 #1
0
        private string GetBodyMailWinnerTender()
        {
            CMO_UploadResult cMO_UploadResult = db.CMO_UploadResult.Include(d => d.CMO_Company).Where(d => d.id_CMO_Tender == idTender).First();
            string           body             = "Добрый день!\nПо итогам торгов победил: " + cMO_UploadResult.CMO_Company.name + "\n\nСтоимость заказа " + cMO_UploadResult.cost.ToString() + " б.р. б/ндс, срок изготовления " + cMO_UploadResult.day.ToString() + "дн.";

            return(body);
        }
예제 #2
0
        private void CloseFirstTenderInUpload()
        {
            var cMO_Tender = db.CMO_UploadResult.Where(d => d.id_CMO_Tender == idTender & d.dateTimeUpload == null).ToList();

            foreach (var data in cMO_Tender)
            {
                CMO_UploadResult tenderU = db.CMO_UploadResult.Find(data.id);
                db.CMO_UploadResult.Remove(tenderU);
                db.SaveChanges();
            }
        }
예제 #3
0
        private void CloseWinnerTenderInOrder()
        {
            double           minData          = db.CMO_UploadResult.Where(d => d.CMO_Tender.id_CMO_Order == idOrder & d.CMO_Tender.id_CMO_TypeTask == 2 & d.cost > 0).Min(d => d.cost);
            CMO_UploadResult getCMOUploadLead = db.CMO_UploadResult.Where(d => d.CMO_Tender.id_CMO_Order == idOrder & d.CMO_Tender.id_CMO_TypeTask == 2 & d.cost > 0 & d.cost == minData).First();
            CMO_Order        cMO_Order        = db.CMO_Order.Find(idOrder);

            cMO_Order.datetimeWinTenderFinish = DateTime.Now;
            cMO_Order.companyWin      = getCMOUploadLead.id_CMO_Company;
            db.Entry(cMO_Order).State = EntityState.Modified;
            db.SaveChanges();
        }
예제 #4
0
 private void CreateCMO_UploadResult(List <int> companyList)
 {
     foreach (var data in companyList)
     {
         CMO_UploadResult cMO_UploadResult = new CMO_UploadResult();
         cMO_UploadResult.id_CMO_Tender  = idTender;
         cMO_UploadResult.cost           = 0;
         cMO_UploadResult.id_CMO_Company = data;
         db.CMO_UploadResult.Add(cMO_UploadResult);
         db.SaveChanges();
     }
 }
예제 #5
0
        private void CreateCMO_Tender(int id_CMO_TypeTask)
        {
            double           minData          = db.CMO_UploadResult.Where(d => d.CMO_Tender.id_CMO_Order == idOrder & d.CMO_Tender.id_CMO_TypeTask == 2 & d.cost > 0).Min(d => d.cost);
            CMO_UploadResult getCMOUploadLead = db.CMO_UploadResult.Where(d => d.CMO_Tender.id_CMO_Order == idOrder & d.CMO_Tender.id_CMO_TypeTask == 2 & d.cost > 0 & d.cost == minData).First();

            CMO_Tender cMO_Tender = new CMO_Tender();

            cMO_Tender.id_CMO_Order    = idOrder;
            cMO_Tender.id_CMO_TypeTask = id_CMO_TypeTask;
            cMO_Tender.close           = true;
            cMO_Tender.finishPlanClose = Convert.ToDateTime(getCMOUploadLead.dateComplited);

            db.CMO_Tender.Add(cMO_Tender);
            db.SaveChanges();
            idTender = cMO_Tender.id;
        }
예제 #6
0
        private DateTime CreateCMO_UploadResult()
        {
            double           minData          = db.CMO_UploadResult.Where(d => d.CMO_Tender.id_CMO_Order == idOrder & d.CMO_Tender.id_CMO_TypeTask == 2 & d.cost > 0).Min(d => d.cost);
            CMO_UploadResult getCMOUploadLead = db.CMO_UploadResult.Where(d => d.CMO_Tender.id_CMO_Order == idOrder & d.CMO_Tender.id_CMO_TypeTask == 2 & d.cost > 0 & d.cost == minData).First();

            CMO_UploadResult cMO_UploadResult = new CMO_UploadResult();

            cMO_UploadResult.id_CMO_Tender  = idTender;
            cMO_UploadResult.dateTimeUpload = DateTime.Now;
            cMO_UploadResult.cost           = getCMOUploadLead.cost;
            cMO_UploadResult.dateComplited  = DateTime.Now.AddDays((int)getCMOUploadLead.day);
            cMO_UploadResult.day            = getCMOUploadLead.day;
            cMO_UploadResult.id_CMO_Company = getCMOUploadLead.id_CMO_Company;
            db.CMO_UploadResult.Add(cMO_UploadResult);
            db.SaveChanges();
            return(Convert.ToDateTime(cMO_UploadResult.dateComplited));
        }
예제 #7
0
        public void GetData()
        {
            SaveFileToServer(@"\\192.168.1.30\m$\_ЗАКАЗЫ\OrderCMO\");
            //re/FacK
            int row     = 9;
            int colCost = 4;

            Excel.Worksheet sheet = null;
            foreach (Excel.Worksheet data in Workbook.Worksheets)
            {
                sheet = data;
                break;
            }
            Excel.Range        range     = sheet.UsedRange;
            List <TenderOffer> offerList = new List <TenderOffer>();
            int countPosition            = 0;

            while (row < 1000)
            {
                TenderOffer offer = new TenderOffer();
                offer.Id_CMO_Order   = Convert.ToInt32(((Excel.Range)range.Cells[row, 1]).Text);
                offer.Id_CMO_Company = 1;
                offer.Cost           = Convert.ToInt32(((Excel.Range)range.Cells[row, colCost]).Text);
                offer.Duration       = Convert.ToInt32(((Excel.Range)range.Cells[row, colCost + 1]).Text);
                offerList.Add(offer);
                offer = new TenderOffer();
                offer.Id_CMO_Order   = Convert.ToInt32(((Excel.Range)range.Cells[row, 1]).Text);
                offer.Id_CMO_Company = 2;
                offer.Cost           = Convert.ToInt32(((Excel.Range)range.Cells[row, colCost + 2]).Text);
                offer.Duration       = Convert.ToInt32(((Excel.Range)range.Cells[row, colCost + 3]).Text);
                offerList.Add(offer);
                offer = new TenderOffer();
                offer.Id_CMO_Order   = Convert.ToInt32(((Excel.Range)range.Cells[row, 1]).Text);
                offer.Id_CMO_Company = 3;
                offer.Cost           = Convert.ToInt32(((Excel.Range)range.Cells[row, colCost + 4]).Text);
                offer.Duration       = Convert.ToInt32(((Excel.Range)range.Cells[row, colCost + 5]).Text);
                offerList.Add(offer);
                row++;
                if (((Excel.Range)range.Cells[row, 1]).Text == "")
                {
                    break;
                }
            }
            int orderId  = 0;
            int tenderId = 0;

            foreach (var VARIABLE in offerList)
            {
                if (orderId != VARIABLE.Id_CMO_Order)
                {
                    CMO_Tender tender = new CMO_Tender();
                    tender.id_CMO_Order    = VARIABLE.Id_CMO_Order;
                    tender.id_CMO_TypeTask = 1;
                    tender.finishPlanClose = DateTime.Now;
                    tender.close           = true;
                    tender.closeDateTime   = DateTime.Now;
                    db.CMO_Tender.Add(tender);
                    db.SaveChanges();
                    tenderId = tender.id;
                    orderId  = tender.id_CMO_Order;
                    CMO_Order order = db.CMO_Order.Find(orderId);
                    order.firstTenderStart = true;
                    db.Entry(order).State  = EntityState.Modified;
                    db.SaveChanges();
                    countPosition++;
                }
                CMO_UploadResult result = new CMO_UploadResult();
                result.id_CMO_Tender  = tenderId;
                result.dateTimeUpload = DateTime.Now;
                result.cost           = VARIABLE.Cost;
                result.dateComplited  = DateTime.Now;
                result.id_CMO_Company = VARIABLE.Id_CMO_Company;
                result.day            = VARIABLE.Duration;
                db.CMO_UploadResult.Add(result);
                db.SaveChanges();
            }
            row      += 4;
            offerList = new List <TenderOffer>();
            for (int i = 0; i < countPosition; i++)
            {
                TenderOffer offer = new TenderOffer();
                offer.Id_CMO_Order   = Convert.ToInt32(((Excel.Range)range.Cells[row, 1]).Text);
                offer.Id_CMO_Company = GetIdCompany(((Excel.Range)range.Cells[row, 4]).Text);
                offer.Cost           = Convert.ToInt32(((Excel.Range)range.Cells[row, 6]).Text);
                offer.Duration       = Convert.ToInt32(((Excel.Range)range.Cells[row, 8]).Text);
                offerList.Add(offer);
                row++;
            }
            foreach (var VARIABLE in offerList)
            {
                CMO_Tender tender = new CMO_Tender();
                tender.id_CMO_Order    = VARIABLE.Id_CMO_Order;
                tender.id_CMO_TypeTask = 3;
                tender.finishPlanClose = DateTime.Now;
                tender.close           = true;
                tender.closeDateTime   = DateTime.Now;
                db.CMO_Tender.Add(tender);
                db.SaveChanges();

                CMO_UploadResult result = new CMO_UploadResult();
                result.id_CMO_Tender  = tender.id;
                result.dateTimeUpload = DateTime.Now;
                result.cost           = VARIABLE.Cost;
                result.dateComplited  = DateTime.Now;
                result.id_CMO_Company = VARIABLE.Id_CMO_Company;
                result.day            = VARIABLE.Duration;
                db.CMO_UploadResult.Add(result);
                db.SaveChanges();

                CMO_Order order = db.CMO_Order.Find(tender.id_CMO_Order);
                order.companyWin      = result.id_CMO_Company;
                db.Entry(order).State = EntityState.Modified;
                db.SaveChanges();
            }
            CloseWorkbook();
        }