Ejemplo n.º 1
0
        private void loadArticleFase()
        {
            List <OperationParameters> art = null;

            art = Exacta.Menu.db.GetTable <OperationParameters>().Where(operation => operation.IdArticol.ToString() == _selectedArticle).ToList();

            lstFases = new List <FaseForArticle>();

            for (var i = 0; i < art.Count; i++)
            {
                Operatii       opers = Exacta.Menu.db.GetTable <Operatii>().Where(operation => operation.Id == art[i].IdOperatie).SingleOrDefault();
                FaseForArticle f     = new FaseForArticle(opers.Operatie, art[i].BucatiOra, art[i].Components);
                lstFases.Add(f);
            }
            var dt = new DataTable();

            dt.Columns.Add("Phase");
            dt.Columns.Add("Pieces/Hour");
            dt.Columns.Add("Components");
            _totalPc         = 0.0;
            _totalComponents = 0;
            foreach (var item in lstFases)
            {
                var newRow = dt.NewRow();
                newRow[0] = item.Fase;
                newRow[1] = item.BucatiOra;
                newRow[2] = item.Components;
                dt.Rows.Add(newRow);
                _totalPc          = _totalPc + (item.BucatiOra * item.Components);
                _totalComponents += item.Components;
            }
            var totalRow = dt.NewRow();

            totalRow[0] = "TOTAL";
            totalRow[1] = _totalPc;
            totalRow[2] = _totalComponents;
            dt.Rows.Add(totalRow);
            dgv_FaseArticles.DataSource = dt;

            dgv_FaseArticles.Columns[1].Width = 90;
            dgv_FaseArticles.Columns[2].Width = 90;
        }
Ejemplo n.º 2
0
        private void PrintFasePDF()
        {
            //article table
            BaseFont  bf       = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, BaseFont.EMBEDDED);
            PdfPTable pdfTable = new PdfPTable(3);

            pdfTable.DefaultCell.Padding     = 3;
            pdfTable.WidthPercentage         = 100;
            pdfTable.HorizontalAlignment     = Element.ALIGN_LEFT;
            pdfTable.DefaultCell.BorderWidth = 1;
            pdfTable.SpacingAfter            = 20;

            //custom font
            string slnPath = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));

            slnPath = slnPath + "\\Fonts\\arial.ttf";
            BaseFont arial = BaseFont.CreateFont(slnPath, BaseFont.CP1250, BaseFont.EMBEDDED);

            iTextSharp.text.Font text = new iTextSharp.text.Font(arial, 10, iTextSharp.text.Font.NORMAL);

            foreach (DataGridViewColumn column in dgvFase.Columns)
            {
                PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, text));
                cell.BackgroundColor = new iTextSharp.text.BaseColor(Color.Coral);
                pdfTable.AddCell(cell);
            }

            Operatii ph = Exacta.Menu.db.GetTable <Operatii>().SingleOrDefault(p => p.Id.ToString() == _selectedFase);

            pdfTable.DefaultCell.BackgroundColor = new iTextSharp.text.BaseColor(Color.White);
            pdfTable.AddCell(new Phrase(ph.Id.ToString(), text));
            pdfTable.AddCell(new Phrase(ph.CodOperatie, text));
            pdfTable.AddCell(new Phrase(ph.Operatie, text));

            //title
            iTextSharp.text.Font titleFont = new iTextSharp.text.Font(arial, 36, iTextSharp.text.Font.NORMAL);
            Paragraph            title     = new Paragraph("Phase Report", titleFont);

            title.Alignment    = Element.ALIGN_CENTER;
            title.SpacingAfter = 20;
            //titleFont.SetColor(169, 169, 169);

            //date
            DateTime dateTime = DateTime.Now;

            iTextSharp.text.Font dateTimeFont = new iTextSharp.text.Font(arial, 16, iTextSharp.text.Font.NORMAL);
            Paragraph            date         = new Paragraph("Date: " + dateTime.ToString("dd-MM-yyyy"), dateTimeFont);

            date.Alignment    = Element.ALIGN_RIGHT;
            date.SpacingAfter = 5;
            //dateFont.SetColor(169, 169, 169);

            //time
            Paragraph time = new Paragraph("Time: " + dateTime.ToString("HH:mm:ss"), dateTimeFont);

            time.Alignment    = Element.ALIGN_RIGHT;
            time.SpacingAfter = 30;

            //line separators
            Paragraph sepLine = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, iTextSharp.text.BaseColor.BLACK, Element.ALIGN_LEFT, 1)));

            sepLine.SpacingAfter = -10;
            Paragraph sepLine2 = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, iTextSharp.text.BaseColor.BLACK, Element.ALIGN_LEFT, 1)));

            sepLine2.SpacingAfter = 40;

            //signature
            iTextSharp.text.Font footFont  = new iTextSharp.text.Font(arial, 16, iTextSharp.text.Font.NORMAL);
            Paragraph            signature = new Paragraph("E X A C T A", footFont);

            signature.Alignment    = Element.ALIGN_LEFT;
            signature.SpacingAfter = 30;

            //printing into pdf
            var sfd = new SaveFileDialog();

            sfd.FileName   = "Phase" + ph.Id.ToString();
            sfd.DefaultExt = ".pdf";
            sfd.Filter     = "PDF(*.pdf)|*.pdf";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create))
                {
                    Document doc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                    PdfWriter.GetInstance(doc, fs);
                    doc.Open();
                    doc.Add(signature);
                    doc.Add(title);
                    doc.Add(date);
                    doc.Add(time);
                    doc.Add(sepLine);
                    doc.Add(sepLine2);
                    doc.Add(pdfTable);

                    doc.Close();
                    fs.Close();
                }
                sfd.Dispose();
            }
        }
Ejemplo n.º 3
0
        private void btn_Save_Fase_Click(object sender, EventArgs e)
        {
            if (_isNewFase)
            //insert new record
            {
                try
                {
                    var lQuery = (from fas in Tables.TblOperatii
                                  where fas.CodOperatie == txt_FaseID.Text
                                  select fas).ToList();

                    if (lQuery.Count > 0)
                    {
                        MessageBox.Show("Fase already exists");
                        return;
                    }

                    Operatii fase = new Operatii();
                    fase.CodOperatie = txt_FaseID.Text;
                    fase.Operatie    = txt_Fase.Text;

                    Tables.TblOperatii.InsertOnSubmit(fase);

                    Exacta.Menu.db.SubmitChanges();

                    dgvFase.Enabled      = true;
                    txt_FaseID.BackColor = Color.White;
                    txt_Fase.BackColor   = Color.White;

                    _isNewFase = false;
                }
                catch (Exception ex)
                {
                    _isNewFase = false;
                    MessageBox.Show(ex.Message);
                }
            }
            else
            //update record
            {
                var dr = MessageBox.Show("Do you want to update " + _selectedFase + "?", "Fase update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dr == DialogResult.No)
                {
                    return;
                }
                try
                {
                    //var lQuery = (from fas in Tables.TblOperatii
                    //                where fas.CodOperatie == txt_FaseID.Text
                    //                select fas).ToList();

                    //if (lQuery.Count > 0)
                    //{
                    //    MessageBox.Show("Fase already exists");
                    //    return;
                    //}

                    var lsQuery = (from fas in Tables.TblOperatii
                                   where fas.Id.ToString() == _selectedFase
                                   select fas).SingleOrDefault();

                    lsQuery.CodOperatie = txt_FaseID.Text;
                    lsQuery.Operatie    = txt_Fase.Text;

                    Exacta.Menu.db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            txt_FaseID.Text = "";
            txt_Fase.Text   = "";

            LoadFase();
            pnl_Edit_Fase.Visible = true;
            //pnl_table_Fase.Left -= (pnl_Edit_Fase.Width + 10);
            btn_Add_Fase.Enabled    = true;
            btn_Modify_Fase.Enabled = true;
            btn_Delete_Fase.Enabled = true;
            dgvFase.Enabled         = true;

            btn_Save_Fase.Enabled   = false;
            btn_Cancel_Fase.Enabled = false;
            txt_Fase.Enabled        = false;
            txt_FaseID.Enabled      = false;
            Additional.FillTheFilter(dgvFase, cbPhase, 1);
        }