Beispiel #1
0
        private void btnin_lt_Click(object sender, RoutedEventArgs e)
        {
            if (GridSearch.XGReport.ActiveRecord == null)
            {
                return;
            }

            DataRowView drvXReport = (GridSearch.XGReport.ActiveRecord as DataRecord).DataItem as DataRowView;
            string      mau_tu_in  = drvXReport["mau_tu_in"].ToString();

            if (StartUp.IsQLHD && mau_tu_in == "1")
            {
                ExMessageBox.Show(395, StartUp.SysObj, "Có chứng từ thuộc mẫu hóa đơn tự in, không in liên tục được!", "", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (StartUp.SysObj.GetOption("M_IN_HOI_CK").ToString() == "1")
            {
                if (ExMessageBox.Show(400, StartUp.SysObj, "Có chắc chắn in tất cả các chứng từ đã được lọc?", "", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                {
                    int        so_lien;
                    List <int> lstSo_lien = new List <int>();

                    if (txtlien.Value != null)
                    {
                        int iRowTmp = FrmTT_SOCTHDA_HDDT.iRow;
                        so_lien = 1;
                        bool isPrint          = false;
                        int  so_lien_xac_minh = 0;
                        int.TryParse(StartUp.DmctInfo["so_lien_xac_minh"].ToString(), out so_lien_xac_minh);

                        int so_lan_in = Convert.ToInt16(Math.Ceiling(Convert.ToDouble(txtlien.Text) / Convert.ToDouble((GridSearch.XGReport.ActiveRecord as DataRecord).Cells["so_lien"].Value)));
                        while (so_lien <= so_lan_in)
                        {
                            for (int i = 1; i < DsPrint.Tables[0].Rows.Count; i++)
                            {
                                string stt_rec = DsPrint.Tables[0].Rows[i]["stt_rec"].ToString();
                                DsPrint.Tables["TablePH"].DefaultView.RowFilter = "stt_rec= '" + stt_rec + "'";
                                DsPrint.Tables["TableCT"].DefaultView.RowFilter = "stt_rec= '" + stt_rec + "'";
                                DsPrint.Tables["TableCT"].DefaultView.Sort      = "stt_rec0";

                                if (so_lien == 1)
                                {
                                    lstSo_lien.Add(Convert.ToInt32(StartUp.GetSo_lien((DataRecord)GridSearch.XGReport.ActiveRecord, stt_rec)));
                                }

                                if (DsPrint.Tables[0].Rows[i]["status"].ToString() != "3")
                                {
                                    int so_lien_hien_thoi = lstSo_lien[i - 1], so_lien_hd = 0;
                                    int.TryParse(DsPrint.Tables["TablePH"].DefaultView[0]["so_lien_hd"].ToString(), out so_lien_hd);

                                    if (so_lien_hien_thoi > so_lien_hd)
                                    {
                                        DsPrint.Tables["TablePH"].DefaultView[0]["ban_sao"] = "BẢN SAO";
                                    }
                                    else
                                    {
                                        if (so_lien <= so_lien_hien_thoi || so_lien > so_lien_hd)
                                        {
                                            DsPrint.Tables["TablePH"].DefaultView[0]["ban_sao"] = "BẢN SAO";
                                        }
                                        else
                                        {
                                            DsPrint.Tables["TablePH"].DefaultView[0]["ban_sao"] = "";
                                        }
                                    }

                                    DsPrint.Tables["TablePH"].DefaultView[0]["so_lien"] = so_lien;

                                    int sl_in = Convert.ToInt16(StartUp.DsTrans.Tables[0].Rows[i]["sl_in"]);


                                    if (mau_tu_in == "1" && sl_in > 0 && !isPrint)
                                    {
                                        if (ExMessageBox.Show(405, StartUp.SysObj, "Hóa đơn đã được in, có muốn in lại hay không?", "", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
                                        {
                                            return;
                                        }

                                        FrmLogin login = new FrmLogin();
                                        login.ShowDialog();
                                        if (!login.IsLogined)
                                        {
                                            return;
                                        }

                                        // da thong bao roi, lan sau ko thong bao nua
                                        isPrint = true;
                                    }


                                    InsertRowCT(mau_tu_in);
                                    GridSearch.V_In(1, (so_lien_xac_minh >= so_lien && string.IsNullOrEmpty(DsPrint.Tables["TablePH"].DefaultView[0]["ban_sao"].ToString())));
                                    if (mau_tu_in == "1" && so_lien == 1 && GridSearch.PrintSuccess)
                                    {
                                        StartUp.UpdateSl_in(stt_rec, drvXReport["id"].ToString(), txtlien.Text);
                                        StartUp.DsTrans.Tables[0].Rows[i]["sl_in"] = StartUp.GetSl_in(stt_rec);
                                    }
                                }
                            }
                            so_lien++;
                        }
                        ResetTableCt();
                        DsPrint.Tables["TablePH"].DefaultView.RowFilter = "stt_rec= '" + DsPrint.Tables["TablePH"].Rows[iRowTmp]["stt_rec"].ToString() + "'";
                        DsPrint.Tables["TableCT"].DefaultView.RowFilter = "stt_rec= '" + DsPrint.Tables["TablePH"].Rows[iRowTmp]["stt_rec"].ToString() + "'";
                        DsPrint.Tables["TableCT"].DefaultView.Sort      = "stt_rec0";
                        StartUp.SetPhIn(this.DataContext as DataTable);
                    }
                    this.Close();
                }
            }
        }
Beispiel #2
0
        private void btnin_Click(object sender, RoutedEventArgs e)
        {
            if (GridSearch.XGReport.ActiveRecord == null)
            {
                return;
            }
            if (txtlien.Value != null)
            {
                int         sl_in      = Convert.ToInt16(StartUp.DsTrans.Tables[0].DefaultView[0]["sl_in"]);
                DataRowView drvXReport = (GridSearch.XGReport.ActiveRecord as DataRecord).DataItem as DataRowView;

                string nd51 = drvXReport["nd51"].ToString();
                if (nd51 == "1" && sl_in > 0)
                {
                    if (ExMessageBox.Show(390, StartUp.SysObj, "Hóa đơn đã được in, có muốn in lại hay không?", "", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
                    {
                        return;
                    }

                    FrmLogin login = new FrmLogin();
                    login.ShowDialog();
                    if (!login.IsLogined)
                    {
                        return;
                    }
                }
                int so_lien = 1, so_lien_hd = 0, so_lien_xac_minh = 0;
                int so_lien_hien_thoi = Convert.ToInt32(StartUp.GetSo_lien((DataRecord)GridSearch.XGReport.ActiveRecord, StartUp.DsTrans.Tables[0].DefaultView[0]["stt_rec"].ToString()));
                int.TryParse(DsPrint.Tables["TablePH"].DefaultView[0]["so_lien_hd"].ToString(), out so_lien_hd);
                int.TryParse(StartUp.DmctInfo["so_lien_xac_minh"].ToString(), out so_lien_xac_minh);

                if (so_lien_hien_thoi > so_lien_hd)
                {
                    DsPrint.Tables["TablePH"].DefaultView[0]["ban_sao"] = "BẢN SAO";
                }
                int so_lan_in = Convert.ToInt16(Math.Ceiling(Convert.ToDouble(txtlien.Text) / Convert.ToDouble((GridSearch.XGReport.ActiveRecord as DataRecord).Cells["so_lien"].Value)));
                while (so_lien <= so_lan_in)
                {
                    DsPrint.Tables["TablePH"].DefaultView[0]["so_lien"] = so_lien;

                    if (so_lien_hien_thoi <= so_lien_hd)
                    {
                        if (so_lien <= so_lien_hien_thoi || so_lien > so_lien_hd)
                        {
                            DsPrint.Tables["TablePH"].DefaultView[0]["ban_sao"] = "BẢN SAO";
                        }
                        else
                        {
                            DsPrint.Tables["TablePH"].DefaultView[0]["ban_sao"] = "";
                        }
                    }

                    InsertRowCT(nd51);
                    GridSearch.V_In(1, (so_lien_xac_minh >= so_lien && string.IsNullOrEmpty(DsPrint.Tables["TablePH"].DefaultView[0]["ban_sao"].ToString())));
                    so_lien++;
                }

                //update sl_in và so_lien in
                if (nd51 == "1" && GridSearch.PrintSuccess)
                {
                    string stt_rec = StartUp.DsTrans.Tables[0].DefaultView[0]["stt_rec"].ToString();
                    StartUp.UpdateSl_in(stt_rec, drvXReport["id"].ToString(), txtlien.Text);
                    StartUp.DsTrans.Tables[0].DefaultView[0]["sl_in"] = StartUp.GetSl_in(stt_rec);
                }
                ResetTableCt();
                StartUp.SetPhIn(this.DataContext as DataTable);
            }
            this.Close();
        }