Esempio n. 1
0
        private void PrintPreview()
        {
            DataGridView dgv    = dataGridView1;
            var          JOB_ID = dgv.SelectedCells[0].Value.ToString();

            //ปริ้นใบแจ้งซ่อม
            Report1 = "SELECT DISTINCT NJ.JOBID,"
                      + " (select U_NAME from COS_USER WHERE U_ID = PO.U_ID)AS NAME, RTRIM(D.DEPNAME)AS DEPTNAME, "
                      + " NJ.TEL, NJ.OWNER, dbo.dmyCOS_hm(NJ.REQ_DATE) AS REQ_DATE, c2c.NAME AS CT_NAME, CT.CAUSE_NAME, NJ.CARUCODE, "
                      + " NJ.CARUNO, dbo.dmyCOS(NJ.EXPECT_DATE) AS EXPECT_DATE, PLC.PL_ID, PLC.PL_ID_C, (ISNULL(PL_NAME, '')) + '' + ISNULL(PL_BRAND, '') + '' + ISNULL(PL_GEN, '') + '' + ISNULL(PL_DESC_C, '') AS PO_NAME, PO.PO_QTY_REQUIRED, UN.ST_NAME AS ST_NAME, U.U_NAME, FT.FT_NAME, "
                      + " C.[Boss_Technician], C.[Boss_Stock], C.[DeputyDirector], C.[Director], dbo.dmyCOS(SUBSTRING(FIXED_DATE, 1, 8))AS FIXED_DATE, "
                      + " dbo.dmyCOS(SUBSTRING(PO_ASSIGN_DATE, 1, 8))AS PO_ASSIGN_DATE, dbo.dmyCOS(SUBSTRING(PO_ASSIGN_DATE_SOTCK, 1, 8))AS PO_ASSIGN_DATE_SOTCK,NJ.MOTIVE,NJ.FIXED_DETAIL,FIXED_DETAIL,(SELECT dbo.dmyCOS(GETDATE()))AS DATE"
                      + " FROM COS_JOB NJ"
                      + " LEFT JOIN COS_CAUSE_TYPE CT ON NJ.CAUSE_ID = CT.CAUSE_ID"
                      + " LEFT JOIN MUHDEP D ON NJ.DEPT_ID = D.DEPCODE"
                      + " LEFT JOIN [CARU2CODE]c2c ON NJ.CARUCODE = c2c.CARUCODE"
                      + " LEFT JOIN COS_LEVEL_TYPE ON NJ.JOB_WANT_ID = COS_LEVEL_TYPE.LEVEL_ID"
                      + " LEFT JOIN COS_FIXED_TYPE ON NJ.FIX_TYPE_ID = COS_FIXED_TYPE.FT_ID"
                      + " LEFT JOIN COS_USER U ON NJ.USER_ID = U.U_ID"
                      + " LEFT JOIN COS_PART_ORDER PO ON PO.JOB_ID = NJ.JOBID"
                      + " LEFT JOIN COS_FIXED_TYPE FT ON FT.FT_ID = NJ.FIX_TYPE_ID"
                      + " LEFT JOIN COS_PART_LIST_C PLC ON PLC.PL_ID = PO.PL_ID AND PLC.PL_ID_C = PO.PL_ID_C"
                      + " LEFT JOIN COS_PART_LIST PL ON PL.PL_ID = PO.PL_ID "
                      + " LEFT JOIN COS_UNIT UN ON UN.ST_UNIT = PL.PL_UNIT"
                      + " CROSS JOIN COS_COS C"
                      + " where NJ.JOBID =  '" + JOB_ID + "'";
            CARUCODE = dgv.SelectedCells[3].Value.ToString();
            CARUNO   = dgv.SelectedCells[4].Value.ToString();

            fmReport1 f = new fmReport1(Report1, CARUCODE, CARUNO);

            f.Dock = DockStyle.Fill;
            f.ShowDialog();
        }
Esempio n. 2
0
        private void PrintPreview(string _Report, string _Carucode, string _caruno)
        {
            try
            {
                if (dgvAssignmentsBoss.SelectedRows.Count > 1)
                {
                }

                if (tabControl1.SelectedIndex == 0)
                {
                    var sql = "update COS_JOB set STATUS_FIX_ID=@STATUS_FIX_ID,BOSS_DATE=@BOSS_DATE"
                              + " where JOB_ID = '" + JOB_ID + "'";
                    SqlParameterCollection param = new SqlCommand().Parameters;
                    param.AddWithValue("@STATUS_FIX_ID", SqlDbType.Int).Value = sf._รอพัสดุรับรายการสั่งซื้อ;
                    param.AddWithValue("@BOSS_DATE", SqlDbType.VarChar).Value = User.GETymd_time();
                    //int i = new DBClass().SqlExecute(sql, param);
                }

                fmReport1 f = new fmReport1(_Report, _Carucode, _caruno);
                f.Dock = DockStyle.Fill;
                f.ShowDialog();
            }
            catch (Exception ex)
            {
                //ถ้างานผิดพลาดให้สั่งปริ้นใหม่
                //var sql = "update COS_PART_ORDER set SPL_ID=@SPL_ID,U_ID=@U_ID,EXPECT_DATE=@EXPECT_DATE,PO_ASSIGN_DATE_SOTCK=@PO_ASSIGN_DATE_SOTCK"
                //                    + " where JOB_ID = '" + JOB_ID + "'";
                //SqlParameterCollection param = new SqlCommand().Parameters;
                //param.AddWithValue("@SPL_ID", SqlDbType.Int).Value = 2;
                //param.AddWithValue("@U_ID", SqlDbType.Int).Value = null;
                //param.AddWithValue("@EXPECT_DATE", SqlDbType.VarChar).Value = null;
                //param.AddWithValue("@PO_ASSIGN_DATE_SOTCK", SqlDbType.VarChar).Value = null;
                //int i = new DBClass().SqlExecute(sql, param);
                MessageBox.Show("ผิดพลาด " + ex.Message + "กรุณาปริ้น JOB " + JOB_ID + "ใหม่อีกที!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }