public static bool SavePrintOrder(Datasource.dsQry.XRepCard1DataTable PrintTbl)
        {
            bool          output     = false;
            SqlConnection con        = new SqlConnection(Properties.Settings.Default.E_CardConnectionString);
            SqlCommand    cmd        = new SqlCommand("INSERT INTO TBLPrintOut (DataId, printdate, datein, userin) VALUES (@DataId, GETDATE(), GETDATE(), @userin)", con);
            SqlParameter  PramDataId = new SqlParameter("@DataId", SqlDbType.Int);
            SqlParameter  Pramuserin = new SqlParameter("@userin", SqlDbType.Int)
            {
                Value = UserManager.UserInfo.UserID
            };

            cmd.Parameters.Add(PramDataId);
            cmd.Parameters.Add(Pramuserin);

            try
            {
                con.Open();
                foreach (Datasource.dsQry.XRepCard1Row row in PrintTbl.Rows)
                {
                    PramDataId.Value = row.DataId;
                    cmd.ExecuteNonQuery();
                }
                output = true;
            }
            catch (SqlException ex)
            {
                Logger.Error(ex.Message, ex);
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error While Saving Printing Order", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            con.Close();
            return(output);
        }
Exemple #2
0
        private void lueCardLayout_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (e.Button.Kind != DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph)
            {
                return;
            }
            if (FXFW.SqlDB.IsNullOrEmpty(lueTBLALLData.EditValue))
            {
                MsgDlg.Show("يجب اختيار من القائمة", MsgDlg.MessageType.Error);
                return;
            }
            Datasource.dsQry.XRepCard1DataTable PrintTbl = new Datasource.dsQry.XRepCard1DataTable();
            for (int i = 0; i < gridViewMain.SelectedRowsCount; i++)
            {
                PrintTbl.Rows.Add(gridViewMain.GetDataRow(gridViewMain.GetSelectedRows()[i]).ItemArray);
            }
            switch (lueCardLayout.SelectedIndex)
            {
            case 0:     //Card 1
                ECard.Forms.XRep.XRepCard1 FrmRep1 = new ECard.Forms.XRep.XRepCard1(PrintTbl);
                ECard.Classes.Misc.ShowPrintPreview(FrmRep1, true);
                break;

            case 1:     //Card 2
                ECard.Forms.XRep.XRepCard2 FrmRep2 = new ECard.Forms.XRep.XRepCard2(PrintTbl);
                ECard.Classes.Misc.ShowPrintPreview(FrmRep2, true);
                break;

            case 2:     //Card 3
                ECard.Forms.XRep.XRepCard3 FrmRep3 = new ECard.Forms.XRep.XRepCard3(PrintTbl);
                ECard.Classes.Misc.ShowPrintPreview(FrmRep3, true);
                break;

            case 3:     //Card 4
                ECard.Forms.XRep.XRepCard4 FrmRep4 = new ECard.Forms.XRep.XRepCard4(PrintTbl);
                ECard.Classes.Misc.ShowPrintPreview(FrmRep4, true);
                break;

            default:
                break;
            }
            //Saving Printing Order
            if (MsgDlg.Show("هل تريد حقظ الطباعة؟", MsgDlg.MessageType.Question) == DialogResult.Yes)
            {
                if (!Classes.Managers.DataManager.SavePrintOrder(PrintTbl))
                {
                    MsgDlg.Show("لم يتم الحفظ", MsgDlg.MessageType.Error);
                    return;
                }
            }
        }