Exemple #1
0
        public static bool PrintListOrder(string Ma_Px, bool bPreview, bool bShowDialog, ref bool bInVisibleNextPrint, ref string strReport_File_First)
        {
            string strMa_Px             = Ma_Px;// (string)drPhView["Ma_Px"];
            string strReportTag         = string.Empty;
            string strTable_Ph          = string.Empty;
            string strTable_Ct          = string.Empty;
            bool   bIs_Vnd              = true;
            string strReport_File       = "rptPXKList";
            bool   bInVisibleNextPrint0 = false;


            DataTable dtHeader;
            DataTable dtDetail;



            Hashtable ht = new Hashtable();

            ht.Add("MA_PX", strMa_Px);
            DataSet dsPrintVoucher = new DataSet();

            dsPrintVoucher = SQLExec.ExecuteReturnDs("sp_PrintListOrder", ht, CommandType.StoredProcedure);

            //Upadte Gia = 0, Tien = 0, TTien = 0 khi in chung tu doi voi User cam ACCESS_PRICE
            DataTable dtPrinVoucherHeader = new DataTable();
            DataTable dtPrinVoucherDetail = new DataTable();

            dtPrinVoucherHeader = dsPrintVoucher.Tables[0];
            dtPrinVoucherDetail = dsPrintVoucher.Tables[1];


            dtHeader = dtPrinVoucherHeader;
            dtDetail = dtPrinVoucherDetail;

            dtHeader.Columns.Add("REPORT_FILE", typeof(string));
            dtHeader.Columns.Add("TITLE", typeof(string));
            dtHeader.Columns.Add("IS_VND", typeof(bool));
            dtHeader.Columns.Add("DOC_TIEN", typeof(string));
            dtHeader.Columns.Add("DOC_TIEN1", typeof(string));

            DataRow drHeader = dtHeader.Rows[0];

            drHeader["Is_Vnd"] = bIs_Vnd;
            drHeader["Title"]  = "DANH SÁCH ĐƠN HÀNG";
            if (bInVisibleNextPrint)
            {
                drHeader["Report_File"] = strReport_File_First;
            }
            else
            {
                drHeader["Report_File"] = strReport_File;
                strReport_File_First    = strReport_File;
                bInVisibleNextPrint     = bInVisibleNextPrint0;
            }


            Epoint.Reports.frmReportPrint frmPrint = new Epoint.Reports.frmReportPrint();
            //frmPrint.MdiParent = Element.frmActiveMain;
            return(frmPrint.Load(dtHeader.Rows[0], dtDetail, bPreview, bShowDialog));
        }
Exemple #2
0
        public static bool Print(DataRow drPhView, bool bPreview, bool bShowDialog, ref bool bInVisibleNextPrint, ref string strReport_File_First)
        {
            string strStt               = (string)drPhView["Stt"];
            string strMa_Ct             = (string)drPhView["Ma_Ct"];
            string strMa_Tte            = "VND";// (string)drPhView["Ma_Tte"];
            string strReportTag         = string.Empty;
            string strTable_Ph          = string.Empty;
            string strTable_Ct          = string.Empty;
            bool   bIs_Vnd              = true;
            string strReport_File       = string.Empty;
            bool   bInVisibleNextPrint0 = false;
            bool   bIs_Doc_Tien1        = false;
            int    iSo_Lien             = 1;

            DataRow   drDmCt = DataTool.SQLGetDataRowByID("SYSDMCT", "Ma_Ct", strMa_Ct);
            DataTable dtHeader;
            DataTable dtDetail;

            strTable_Ph    = (string)drDmCt["Table_Ph"];
            strTable_Ct    = (string)drDmCt["Table_Ct"];
            strReport_File = (string)drDmCt["Report_File"];

            if (strMa_Ct == "BN" && !bInVisibleNextPrint)
            {
                DataRow drCtTien = DataTool.SQLGetDataRowByID(strTable_Ct, "Stt", strStt);

                if (!drPhView.Table.Columns.Contains("TK_NH"))
                {
                    drPhView.Table.Columns.Add("TK_NH", typeof(string));
                }

                drPhView["Tk_Nh"] = (string)drCtTien["Tk_Co"];

                frmIn_CT_UNC frm = new frmIn_CT_UNC();

                if (strMa_Tte != Element.sysMa_Tte)
                {
                    frm.rdbTien_Nt.Checked = true;
                }

                frm.Load(drPhView);

                if (!frm.isAccept)
                {
                    return(false);
                }

                bInVisibleNextPrint0 = frm.chkInVisibleNextPrint.Checked;
                bIs_Vnd = frm.rdbTien_VND.Checked;

                strReport_File = frm.cboMau_In.SelectedValue.ToString();
                iSo_Lien       = frm.iSo_Lien;
            }
            else
            {
                //In thông tin chữ ký
                string strName1 = string.Empty;
                string strName2 = string.Empty;
                string strName3 = string.Empty;
                string strName4 = string.Empty;
                string strName5 = string.Empty;

                string    strKey = "Ma_Dvcs = '" + Element.sysMa_DvCs + "'" + " AND Ma_Ct = '" + strMa_Ct + "'";
                DataTable dtDmCk = DataTool.SQLGetDataTable("SYSDMCK", "*", strKey, "Ma_Ct");
                if (dtDmCk != null)
                {
                    foreach (DataRow drDmCk in dtDmCk.Rows)
                    {
                        strName1 = drDmCk["Name1"].ToString();
                        strName2 = drDmCk["Name2"].ToString();
                        strName3 = drDmCk["Name3"].ToString();
                        strName4 = drDmCk["Name4"].ToString();
                        strName5 = drDmCk["Name5"].ToString();
                    }
                }

                //Cập nhật thông tin chữ ký xuống GLVOUCHER

                string strSQLUpdate = "UPDATE " + strTable_Ph + " SET " +
                                      @"Chu_Ky_1 = @Chu_Ky_1, Chu_Ky_2 = @Chu_Ky_2, Chu_Ky_3 = @Chu_Ky_3, Chu_Ky_4 = @Chu_Ky_4, Chu_Ky_5 = @Chu_Ky_5" +
                                      " WHERE Stt = @Stt";

                Hashtable htChuKy = new Hashtable();
                htChuKy["CHU_KY_1"] = strName1;
                htChuKy["CHU_KY_2"] = strName2;
                htChuKy["CHU_KY_3"] = strName3;
                htChuKy["CHU_KY_4"] = strName4;
                htChuKy["CHU_KY_5"] = strName5;
                htChuKy["STT"]      = strStt;

                SQLExec.Execute(strSQLUpdate, htChuKy, CommandType.Text);

                //In Tien_Nt
                if (strMa_Tte != Element.sysMa_Tte)
                {
                    frmIn_CT_Tien_NT frm = new frmIn_CT_Tien_NT();
                    frm.Load(drPhView);

                    if (!frm.isAccept)
                    {
                        return(false);
                    }

                    bIs_Vnd = frm.rdbTien_VND.Checked;
                }
            }

            //Chon nhieu mau report khi in
            DataTable dtDmMauIn = DataTool.SQLGetDataTable("SYSDMMAUCT", "Ma_Mau, Ten_Mau", "Ma_Ct = '" + strMa_Ct + "'", "Ma_Mau");

            if (dtDmMauIn.Rows.Count == 1)
            {
                strReport_File = (string)dtDmMauIn.Rows[0]["Ma_Mau"];
            }
            else if (strMa_Ct != "BN" && dtDmMauIn.Rows.Count > 1 && !bInVisibleNextPrint)
            {
                if (strMa_Ct == "PC" || strMa_Ct == "PT")
                {
                    frmIn_Ct_Khac frmInHD = new frmIn_Ct_Khac();
                    frmInHD.strMa_Ct  = strMa_Ct;
                    frmInHD.Is_Design = false;
                    frmInHD.Load(drPhView);

                    strReport_File       = frmInHD.cboMau_In.SelectedValue.ToString();
                    iSo_Lien             = frmInHD.iSo_Lien;
                    bInVisibleNextPrint0 = frmInHD.chkInVisibleNextPrint.Checked;
                    bIs_Doc_Tien1        = frmInHD.chkIs_Doc_Tien1.Checked;
                    if (!frmInHD.Is_Design)
                    {
                        return(false);
                    }
                }
                else
                {
                    frmIn_Ct_HD frmInHD = new frmIn_Ct_HD();
                    frmInHD.strMa_Ct  = strMa_Ct;
                    frmInHD.Is_Design = false;
                    frmInHD.Load(drPhView);

                    strReport_File       = frmInHD.cboMau_In.SelectedValue.ToString();
                    iSo_Lien             = frmInHD.iSo_Lien;
                    bInVisibleNextPrint0 = frmInHD.chkInVisibleNextPrint.Checked;

                    if (!frmInHD.Is_Design)
                    {
                        return(false);
                    }
                }
            }
            string strMau_So = string.Empty;

            if (drPhView.Table.Columns.Contains("Mau_So"))
            {
                strMau_So = (string)drPhView["Mau_So"];
            }

            Hashtable ht = new Hashtable();

            ht.Add("STT", strStt);
            ht.Add("MA_CT", strMa_Ct);
            ht.Add("IS_VND", bIs_Vnd ? 1 : 0);
            ht.Add("LANGUAGE_TYPE", (char)Element.sysLanguage);

            DataSet dsPrintVoucher = SQLExec.ExecuteReturnDs("sp_PrintVoucher", ht, CommandType.StoredProcedure);

            //Upadte Gia = 0, Tien = 0, TTien = 0 khi in chung tu doi voi User cam ACCESS_PRICE
            DataTable dtPrinVoucherHeader = new DataTable();
            DataTable dtPrinVoucherDetail = new DataTable();

            dtPrinVoucherHeader = dsPrintVoucher.Tables[0];
            dtPrinVoucherDetail = dsPrintVoucher.Tables[1];
            if (DataTool.SQLCheckExist("SYSOBJECT", "Object_ID", "ACCESS_PRICE") && !Common.CheckPermission("ACCESS_PRICE", enuPermission_Type.Allow_Access))
            {
                foreach (DataColumn dc in dtPrinVoucherHeader.Columns)
                {
                    if (dc.ColumnName.StartsWith("GIA") || dc.ColumnName.StartsWith("TIEN") || dc.ColumnName.StartsWith("TTIEN") || dc.ColumnName.StartsWith("PS_NO") || dc.ColumnName.StartsWith("PS_CO") || dc.ColumnName.StartsWith("PS_TANG") || dc.ColumnName.StartsWith("PS_GIAM") || dc.ColumnName.StartsWith("DU_DAU") || dc.ColumnName.StartsWith("DU_CUOI") || dc.ColumnName.StartsWith("DU_NO") || dc.ColumnName.StartsWith("DU_CO"))
                    {
                        if (dc.DataType == typeof(double) || dc.DataType == typeof(decimal))
                        {
                            //Gán cột dữ liệu về 0
                            foreach (DataRow dr in dtPrinVoucherHeader.Rows)
                            {
                                dr[dc] = 0;
                            }
                        }
                        if (dc.DataType == typeof(string))
                        {
                            //Gán cột dữ liệu về rổng
                            foreach (DataRow dr in dtPrinVoucherHeader.Rows)
                            {
                                dr[dc] = "";
                            }
                        }
                    }
                }
                foreach (DataColumn dc in dtPrinVoucherDetail.Columns)
                {
                    if (dc.ColumnName.StartsWith("GIA") || dc.ColumnName.StartsWith("TIEN") || dc.ColumnName.StartsWith("PS_NO") || dc.ColumnName.StartsWith("PS_CO") || dc.ColumnName.StartsWith("PS_TANG") || dc.ColumnName.StartsWith("PS_GIAM") || dc.ColumnName.StartsWith("DU_DAU") || dc.ColumnName.StartsWith("DU_CUOI") || dc.ColumnName.StartsWith("DU_NO") || dc.ColumnName.StartsWith("DU_CO"))
                    {
                        if (dc.DataType == typeof(double) || dc.DataType == typeof(decimal))
                        {
                            //Gán cột dữ liệu về 0
                            foreach (DataRow dr in dtPrinVoucherDetail.Rows)
                            {
                                dr[dc] = 0;
                            }
                        }
                    }
                }
            }

            dtHeader = dtPrinVoucherHeader;
            dtDetail = dtPrinVoucherDetail;

            dtHeader.Columns.Add("REPORT_FILE", typeof(string));
            dtHeader.Columns.Add("TITLE", typeof(string));
            dtHeader.Columns.Add("IS_VND", typeof(bool));
            dtHeader.Columns.Add("DOC_TIEN", typeof(string));
            dtHeader.Columns.Add("DOC_TIEN1", typeof(string));
            dtHeader.Columns.Add("DOC_TIEN_TC", typeof(string));

            DataRow drHeader = dtHeader.Rows[0];

            drHeader["Is_Vnd"] = bIs_Vnd;
            drHeader["Title"]  = ((string)drDmCt["Title"]).ToUpper();
            if (bInVisibleNextPrint)
            {
                drHeader["Report_File"] = strReport_File_First;
            }
            else
            {
                drHeader["Report_File"] = strReport_File;
                strReport_File_First    = strReport_File;
                bInVisibleNextPrint     = bInVisibleNextPrint0;
            }

            if (Element.sysLanguage == enuLanguageType.Vietnamese)
            {
                dtHeader.Rows[0]["Doc_Tien"] = !bIs_Vnd?Common.ReadMoney(Convert.ToDouble(drHeader["TTien_Nt"]), strMa_Tte) : Common.ReadMoney(Convert.ToDouble(drHeader["TTien"]), Element.sysMa_Tte.ToString());

                if (drHeader.Table.Columns.Contains("TTien_Nt00"))
                {
                    dtHeader.Rows[0]["Doc_Tien_Tc"] = !bIs_Vnd?Common.ReadMoney(Convert.ToDouble(drHeader["TTien_Nt00"]), strMa_Tte) : Common.ReadMoney(Convert.ToDouble(drHeader["TTien_Nt00"]), Element.sysMa_Tte.ToString());

                    dtHeader.Rows[0]["Doc_Tien_Tc"] = "(" + dtHeader.Rows[0]["Doc_Tien_Tc"].ToString() + ")";
                }
                if (bIs_Doc_Tien1)
                {
                    dtHeader.Rows[0]["Doc_Tien1"] = "";
                }
                else
                {
                    dtHeader.Rows[0]["Doc_Tien1"] = !bIs_Vnd?Common.ReadMoney(Convert.ToDouble(drHeader["TTien_Nt"]), strMa_Tte) : Common.ReadMoney(Convert.ToDouble(drHeader["TTien"]), Element.sysMa_Tte.ToString());
                }
            }
            else
            {
                dtHeader.Rows[0]["Doc_Tien"] = !bIs_Vnd?Common.ReadMoneyE(Convert.ToDouble(drHeader["TTien_Nt"]), strMa_Tte) : Common.ReadMoneyE(Convert.ToDouble(drHeader["TTien"]), Element.sysMa_Tte.ToString());

                if (bIs_Doc_Tien1)
                {
                    dtHeader.Rows[0]["Doc_Tien1"] = "";
                }
                else
                {
                    dtHeader.Rows[0]["Doc_Tien1"] = !bIs_Vnd?Common.ReadMoneyE(Convert.ToDouble(drHeader["TTien_Nt"]), strMa_Tte) : Common.ReadMoneyE(Convert.ToDouble(drHeader["TTien"]), Element.sysMa_Tte.ToString());
                }
            }

            Epoint.Reports.frmReportPrint frmPrint = new Epoint.Reports.frmReportPrint();
            //frmPrint.MdiParent = Element.frmActiveMain;
            return(frmPrint.Load(dtHeader.Rows[0], dtDetail, bPreview, bShowDialog));
        }