コード例 #1
0
		public QueryDef(DAO.QueryDef _qd)
		{
			qd=_qd;
		}
コード例 #2
0
ファイル: Welcome.cs プロジェクト: minhbvhp/CongNo
        private void Start_Click(object sender, EventArgs e)
        {
            if (comboNam.Visible)
            {
                Program.DbYear = comboNam.SelectedItem.ToString();
            }
            else
            {
                Program.DbYear = numericNam.Value.ToString();
            }

            String   DBFileName = Program.DbYear + ".mdb";
            FileInfo fileInfo   = new FileInfo(Environment.CurrentDirectory + @"\Database\" + DBFileName);

            if (!fileInfo.Exists)
            {
                Directory.CreateDirectory(Environment.CurrentDirectory + @"\Database");
                using (Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CongNo.DB.mdb"))
                {
                    using (FileStream ResourceFile = new FileStream(fileInfo.ToString(), FileMode.Create, FileAccess.Write))
                    {
                        s.CopyTo(ResourceFile);
                    }
                }

                String db_file = fileInfo.ToString();

                DAO.DBEngine dBEngine = new DAO.DBEngine();
                DAO.Database db;
                db = dBEngine.OpenDatabase(db_file);
                String queryName = "cong_no_draft";
                String querySql  = String.Format("SELECT invoice.ngay_ct, invoice.ngay_hoa_don, department.ma_phong," +
                                                 " department.ten_phong, customers.mst, customers.cong_ty, " +
                                                 "invoice.ki_hieu_hoa_don, invoice.so_hoa_don, invoice.han_thanh_toan, revenue.ma_nv, revenue.user_nhap, invoice.kenh_kt, " +
                                                 "revenue.so_tai_khoan, revenue.so_tham_chieu, invoice.loai_tien, invoice.tong_nguyen_te, " +
                                                 "IIf(Year(invoice.ngay_ct)<{0},invoice.so_tien_phat_sinh) AS du_dau_ky, IIf(Year(invoice.ngay_ct)={0} " +
                                                 "And Month(invoice.ngay_ct)=1,invoice.so_tien_phat_sinh) AS no1, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=2,invoice.so_tien_phat_sinh) AS no2, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=3,invoice.so_tien_phat_sinh) AS no3, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=4,invoice.so_tien_phat_sinh) AS no4, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=5,invoice.so_tien_phat_sinh) AS no5, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=6,invoice.so_tien_phat_sinh) AS no6, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=7,invoice.so_tien_phat_sinh) AS no7, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=8,invoice.so_tien_phat_sinh) AS no8, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=9,invoice.so_tien_phat_sinh) AS no9, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=10,invoice.so_tien_phat_sinh) AS no10, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=11,invoice.so_tien_phat_sinh) AS no11, IIf(Year(invoice.ngay_ct)={0} And " +
                                                 "Month(invoice.ngay_ct)=12,invoice.so_tien_phat_sinh) AS no12 FROM department " +
                                                 "INNER JOIN((revenue INNER JOIN invoice ON (revenue.ki_hieu_hoa_don = invoice.ki_hieu_hoa_don)" +
                                                 " AND(revenue.so_hoa_don = invoice.so_hoa_don)) INNER JOIN customers ON invoice.mst = customers.mst)" +
                                                 " ON department.ma_phong = revenue.ma_phong ORDER BY invoice.ki_hieu_hoa_don, invoice.so_hoa_don;", Program.DbYear);

                DAO.QueryDef cong_no_draft = new DAO.QueryDef();
                cong_no_draft.Name = queryName;
                cong_no_draft.SQL  = querySql;

                db.QueryDefs.Append(cong_no_draft);
                db.Close();
            }

            Form form1 = new Form1();

            this.Hide();
            form1.Show();

            Program.OpenDetailFormOnClose = true;
            this.Close();
        }