Beispiel #1
0
        /// <summary>
        /// This is the method that requires the DAL layer to get data from the system,
        /// then use the obtained data to process the login request from Login tier
        /// </summary>
        /// <param name="id"></param>
        /// <param name="pass"></param>
        /// <returns>true if login success, else false</returns>
        public Customer LoginSuccess(string id, string pass)
        {
            Customer  cus = null;
            DataTable dt  = connector.getDataTable("CUSTOMER");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i][1].ToString().Trim().Equals(id) ||
                    dt.Rows[i][2].ToString().Trim().Equals(id))
                {
                    if (dt.Rows[i][3].ToString().Trim().Equals(pass))
                    {
                        cus              = new Customer();
                        cus.HoTen        = dt.Rows[i][0].ToString().Trim();
                        cus.DienThoai    = dt.Rows[i][1].ToString().Trim();
                        cus.DiaChiEmail  = dt.Rows[i][2].ToString().Trim();
                        cus.MatKhau      = dt.Rows[i][3].ToString().Trim();
                        cus.sex          = (bool)dt.Rows[i][4];
                        cus.NgaySinh     = dt.Rows[i][5].ToString();
                        cus.TinhThanhPho = dt.Rows[i][6].ToString();
                        cus.QuanHuyen    = dt.Rows[i][7].ToString();
                        cus.DiaChi       = dt.Rows[i][8].ToString();
                        return(cus);
                    }
                }
            }
            connector.CloseConnection();
            return(cus);
        }
Beispiel #2
0
        public Form1()
        {
            InitializeComponent();
            dataConnector = new DataConnector();

            dataConnector.OpenConnection("all");
            // Recupera os relatórios em formato Crystal Reports ( Categoria C )
            ReportingDocumentDAO        reportingDocumentDAO = new ReportingDocumentDAO(dataConnector.SqlServerConnection);
            List <ReportingDocumentDTO> reportList           = reportingDocumentDAO.GetReports("Category = 'C'");
            // Recupera dados do firebird
            ProdutoDAO               productDAO        = new ProdutoDAO(dataConnector.FirebirdConnection);
            List <ProdutoDTO>        productList       = productDAO.GetAll();
            CidadeDAO                cidadeDAO         = new CidadeDAO(dataConnector.FirebirdConnection);
            List <CidadeDTO>         cityList          = cidadeDAO.GetAll();
            FormaPagamentoDAO        formaPagamentoDAO = new FormaPagamentoDAO(dataConnector.FirebirdConnection);
            List <FormaPagamentoDTO> paymentMethodList = formaPagamentoDAO.GetAll();

            dataConnector.CloseConnection();

            cmbReport.Items.AddRange(reportList.ToArray());
            cmbReport.SelectedIndex = 0;

            cmbProduct.Items.AddRange(productList.ToArray());
            cmbProduct.SelectedIndex = 0;

            cmbCity.Items.AddRange(cityList.ToArray());
            cmbCity.SelectedIndex = 0;

            cmbPaymentMethod.Items.AddRange(paymentMethodList.ToArray());
            cmbPaymentMethod.SelectedIndex = 0;
        }
Beispiel #3
0
        public Form2()
        {
            InitializeComponent();
            dataConnector = new DataConnector();

            dataConnector.OpenConnection("sqlServer");
            ReportingDocumentDAO reportingDocumentDAO = new ReportingDocumentDAO(dataConnector.SqlServerConnection);
            ReportingElementDAO  reportingElementDAO  = new ReportingElementDAO(dataConnector.SqlServerConnection);

            ReportingDocumentDTO reportDoc = reportingDocumentDAO.GetReport(docCode);
            Bitmap   bmp    = new Bitmap(reportDoc.Width, reportDoc.Height);
            Graphics graphs = Graphics.FromImage(bmp);

            graphs.Clear(System.Drawing.Color.White);

            List <ReportingElementDTO> elementList = reportingElementDAO.GetElements(docCode, "Type=10");

            foreach (ReportingElementDTO element in elementList)
            {
                Rectangle rect = new Rectangle(element.left, element.top, element.width, element.height);
                graphs.FillRectangle(new SolidBrush(System.Drawing.Color.LightYellow), rect);
                if (element.borderTop > 0)
                {
                    graphs.DrawRectangle(new Pen(System.Drawing.Color.Black, element.borderTop), rect);
                }
                if (element.borderBottom > 0)
                {
                    graphs.DrawRectangle(new Pen(System.Drawing.Color.Black, element.borderBottom), rect);
                }
                if (element.borderLeft > 0)
                {
                    graphs.DrawRectangle(new Pen(System.Drawing.Color.Black, element.borderLeft), rect);
                }
                if (element.borderRight > 0)
                {
                    graphs.DrawRectangle(new Pen(System.Drawing.Color.Black, element.borderRight), rect);
                }
            }

            List <ReportingElementDTO> imageList = reportingElementDAO.GetElements(docCode, "Type=11");

            foreach (ReportingElementDTO image in imageList)
            {
                Rectangle rect   = new Rectangle(image.left, image.top, image.width, image.height);
                Bitmap    bitmap = new Bitmap(bitmapPath + image.caption);
                graphs.DrawImage(bitmap, rect);
            }

            graphs.Flush();
            imgReport.Image = bmp;

            dataConnector.CloseConnection();
        }
Beispiel #4
0
        public void Load()
        {
            DataConnector dataConnector = new DataConnector();

            dataConnector.OpenConnection("mySql");

            WorkflowDAO workflowDAO = new WorkflowDAO(dataConnector.MySqlConnection);
            ElementDAO  elementDAO  = new ElementDAO(dataConnector.MySqlConnection);
            RelationDAO relationDAO = new RelationDAO(dataConnector.MySqlConnection);

            dataConnector.CloseConnection();
        }
Beispiel #5
0
        public void Store()
        {
            DataConnector dataConnector = new DataConnector();

            dataConnector.OpenConnection("mySql");

            WorkflowDAO workflowDAO = new WorkflowDAO(dataConnector.MySqlConnection);
            ElementDAO  elementDAO  = new ElementDAO(dataConnector.MySqlConnection);
            RelationDAO relationDAO = new RelationDAO(dataConnector.MySqlConnection);

            WorkflowDTO workflowDTO = new WorkflowDTO();

            workflowDTO.id   = this.id;
            workflowDTO.name = this.name;
            if (this.startElement != null)
            {
                workflowDTO.startElement = this.startElement.id;
            }
            if (this.finishElement != null)
            {
                workflowDTO.finishElement = this.finishElement.id;
            }
            this.id = (int)workflowDAO.StoreWorkflow(workflowDTO);

            foreach (FlowElement element in elements)
            {
                ElementDTO elementDTO = new ElementDTO();
                elementDTO.id          = element.id;
                elementDTO.owner       = this.id;
                elementDTO.name        = element.name;
                elementDTO.enabled     = element.enabled;
                elementDTO.elementType = element.elementType;

                elementDAO.StoreElement(elementDTO);
            }

            foreach (Relation relation in relations)
            {
                RelationDTO relationDTO = new RelationDTO();
                relationDTO.origin      = relation.origin.id;
                relationDTO.destinarion = relation.destination.id;

                relationDAO.StoreRelation(relationDTO);
            }

            dataConnector.CloseConnection();
        }
Beispiel #6
0
        private void ExportProducts()
        {
            dataConnector.OpenConnection("firebird");

            int currentRow = 0;

            CreateDataTable(new String[] { "Código", "Descrição", "Unidade" }, new int[] { 100, 500, 50 }, 2000);
            ProdutoDAO        produtoDAO  = new ProdutoDAO(dataConnector.FirebirdConnection);
            List <ProdutoDTO> productList = produtoDAO.GetAll();

            foreach (ProdutoDTO product in productList)
            {
                InsertRow(currentRow, new Object[] { product.codigo, product.descricao, product.unidade });
                currentRow++;
            }
            document.Save(fileStream);
            fileStream.Close();

            dataConnector.CloseConnection();
        }
Beispiel #7
0
        private static void ProcessMailingList()
        {
            DataConnector dataConnector = new DataConnector();

            dataConnector.OpenConnection();

            primaryServer   = dataConnector.GetServer("Primary");
            secondaryServer = dataConnector.GetServer("Secondary");

            // Busca o servidor de envio que trabalha na porta 587 ( porta que o NET Smtp Client aceita )
            SmtpServerDAO        smtpServerDAO = new SmtpServerDAO(dataConnector.MySqlConnection);
            List <SmtpServerDTO> serverList    = smtpServerDAO.GetServers("porta=587");
            SmtpServerDTO        smtpServer    = null;

            if (serverList.Count == 1)
            {
                smtpServer = serverList[0];
            }

            String            listaEnvio  = "";
            MailingDAO        mailingDAO  = new MailingDAO(dataConnector.MySqlConnection);
            List <MailingDTO> mailingList = mailingDAO.GetMailings(null);

            foreach (MailingDTO mailing in mailingList)
            {
                // Verifica se hoje é o dia do faturamento
                Boolean isBillingTime  = false;
                int     diaFaturamento = mailing.diaFaturamento;
                if (diaFaturamento < 1)
                {
                    diaFaturamento = 1;                     // Consiste o dia para casos onde o usuário entrou um número negativo ou zero
                }
                int daysInMonth = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
                if (diaFaturamento > daysInMonth)
                {
                    diaFaturamento = daysInMonth;                               // Consiste o dia para casos onde exceda a quantidade de dias do mês
                }
                isBillingTime = (diaFaturamento == DateTime.Now.Day);

                // Verifica se já foi enviado hoje
                Boolean alreadySent = mailing.ultimoEnvio.Date == DateTime.Now.Date;

                if ((isBillingTime) && (!alreadySent) && (smtpServer != null))
                {
                    Boolean active = AreContractsActive(dataConnector, mailing);
                    if (active)
                    {
                        SendMailing(dataConnector, mailing, smtpServer);
                        listaEnvio += " Cliente: " + mailing.businessPartnerCode + " - " + mailing.businessPartnerName + " Enviado para: " + mailing.destinatarios + Environment.NewLine;
                    }
                }
            }
            if (String.IsNullOrEmpty(listaEnvio))
            {
                listaEnvio = "Vazia";
            }
            if (EventLog.SourceExists("Billing Mailer"))
            {
                EventLog.WriteEntry("Billing Mailer", "Lista de envio -> " + Environment.NewLine + listaEnvio);
            }

            dataConnector.CloseConnection();
        }