Beispiel #1
0
        public BURModel FillEditor(string BUR_Number)
        {
            BURModel BUR = new Entities.BURModel();

            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = Properties.Resources.ConnectionStringLocal;

            using (conn)
            {
                SqlCommand comm = new SqlCommand(
                    "SELECT * FROM dbo.tbl_BUR " +
                    "WHERE BUR_No = '" + BUR_Number + "'", conn);

                conn.Open();

                SqlDataReader reader = comm.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        BUR.BURNumber     = reader.GetString(1);
                        BUR.Date          = reader.GetDateTime(2).ToString();
                        BUR.OfficeCode    = reader.GetString(3);
                        BUR.BDHead_Number = reader.GetString(4);
                        BUR.BStaff_Number = reader.GetString(5);
                        BUR.Payee_Number  = reader.GetString(6);
                        BUR.PRNumber      = reader.GetString(7);
                        BUR.Description   = reader.GetString(8);
                    }
                }
            }

            BUR = FillParticulars(BUR);

            return(BUR);
        }
Beispiel #2
0
        public void createBURExcel(Entities.BURModel SentBUR)
        {
            Entities.BURModel BUR = SentBUR;

            ExApp         = new Excel.Application();
            ExApp.Visible = false;
            ExBook        = ExApp.Workbooks.Open("C:\\BUR.xls");
            ExSheet       = (Excel.Worksheet)ExBook.Sheets[2];
            int     lastRow = 20;
            decimal total   = 0.00M;

            ExSheet.Cells[6, 7] = BUR.BURNumber;
            ExSheet.Cells[7, 2] = BUR.Payee;

            if (BUR.Office != "External")
            {
                ExSheet.Cells[8, 2] = BUR.Office;
            }

            ExSheet.Cells[12, 2] = BUR.Description + "\n" + "PR Number: " + BUR.PRNumber;

            foreach (var item in BUR.Particulars)
            {
                ExSheet.Cells[lastRow, 2] = item.Name;
                ExSheet.Cells[lastRow, 6] = item.Classification;
                //item.Code = item.Code.Insert(1, "-");
                //item.Code = item.Code.Insert(4, "-");
                //item.Code = item.Code.Insert(7, "-");
                ExSheet.Cells[lastRow, 7] = item.Code;
                ExSheet.Cells[lastRow, 8] = item.Amount.ToString("C2");

                total += item.Amount;
                lastRow++;
            }

            ExSheet.Cells[34, 8] = total;

            if (BUR.Office == "External")
            {
                ExSheet.Cells[41, 2] = BUR.OfficeheadName;
                ExSheet.Cells[42, 2] = BUR.OfficeheadPos;
            }
            else
            {
                ExSheet.Cells[41, 2] = BUR.OfficeheadName;
                ExSheet.Cells[42, 2] = BUR.OfficeheadPos;
            }

            ExSheet.Cells[44, 2] = DateTime.Now;

            ExSheet.Cells[41, 7] = BUR.BDHead;
            ExSheet.Cells[42, 7] = BUR.BDHead_Pos;
            ExSheet.Cells[44, 7] = DateTime.Now;

            ExBook.SaveAs("DBMS\\BUR\\BUR_" + BUR.BURNumber + ".xls");

            if (MessageBox.Show("Do you want to continue to printing?", "Print?",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                ExSheet.PrintOutEx();
            }

            ExApp.Visible = true;
            ExSheet.PrintPreview();
            ExBook.Close();
        }