Example #1
0
 ///<summary></summary>
 public static int NonQEx(string[] commands)
 {
     for (int i = 0; i < commands.Length; i++)
     {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             GeneralB.NonQ(commands[i], false);
         }
         else
         {
             DtoGeneralNonQ dto = new DtoGeneralNonQ();
             dto.Command     = commands[i];
             dto.GetInsertID = false;
             RemotingClient.ProcessCommand(dto);
         }
     }
     return(0);
 }
Example #2
0
 ///<summary>This is for multiple queries all concatenated together with ;</summary>
 public static DataSet GetDataSet(string commands)
 {
     try {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             return(GeneralB.GetDataSet(commands));
         }
         else
         {
             DtoGeneralGetDataSet dto = new DtoGeneralGetDataSet();
             dto.Commands = commands;
             return(RemotingClient.ProcessQuery(dto));
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
         return(new DataSet());
     }
 }
Example #3
0
 ///<summary>Use this for count(*) queries.  They are always guaranteed to return one and only one value.  Not any faster, just handier.  Can also be used when retrieving prefs manually, since they will also return exactly one value</summary>
 public static string GetCount(string command)
 {
     try {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             return(GeneralB.GetTable(command).Tables[0].Rows[0][0].ToString());
         }
         else
         {
             DtoGeneralGetTable dto = new DtoGeneralGetTable();
             dto.Command = command;
             return(RemotingClient.ProcessQuery(dto).Tables[0].Rows[0][0].ToString());
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
         return("");
     }
 }
Example #4
0
 ///<summary>This query is run with full privileges.  This is for commands generated by the main program, and the user will not have access for injection attacks.  Result is usually number of rows changed, or can be insert id if requested.</summary>
 public static int NonQ(string command, bool getInsertID)
 {
     try {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             return(GeneralB.NonQ(command, getInsertID));
         }
         else
         {
             DtoGeneralNonQ dto = new DtoGeneralNonQ();
             dto.Command     = command;
             dto.GetInsertID = getInsertID;
             return(RemotingClient.ProcessCommand(dto));
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
         return(0);
     }
 }
Example #5
0
 ///<summary>This is the new way.  If there are more than about 3 parameters, then we'll have to create a different DTO to pass them.  This has not been done yet.  A dataset would be used to pass the parameters up because the information can be better organized, and properly keyed.  But for typical cases with just one or a few parameters, this works great.</summary>
 public static DataSet GetDS(string methodName, string[] parameters)
 {
     try {
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             return(GeneralB.GetDS(methodName, parameters));
         }
         else
         {
             DtoGetDS dto = new DtoGetDS();
             dto.MethodName = methodName;
             dto.Parameters = parameters;
             return(RemotingClient.ProcessGetDS(dto));
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
         return(new DataSet());
     }
 }
Example #6
0
        /*
         * ///<summary></summary>
         * public static Document[] GetAllWithPat(int patNum) {
         *      string command="SELECT * FROM document WHERE WithPat="+POut.PInt(patNum);
         *      return RefreshAndFill(command);
         * }*/

        private static Document[] RefreshAndFill(string command)
        {
            DataSet ds = null;

            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    ds = GeneralB.GetTable(command);
                }
                else
                {
                    DtoGeneralGetTable dto = new DtoGeneralGetTable();
                    dto.Command = command;
                    ds          = RemotingClient.ProcessQuery(dto);
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
            DataTable table = ds.Tables[0];

            Document[] List = new Document[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i]                = new Document();
                List[i].DocNum         = PIn.PInt(table.Rows[i][0].ToString());
                List[i].Description    = PIn.PString(table.Rows[i][1].ToString());
                List[i].DateCreated    = PIn.PDate(table.Rows[i][2].ToString());
                List[i].DocCategory    = PIn.PInt(table.Rows[i][3].ToString());
                List[i].WithPat        = PIn.PInt(table.Rows[i][4].ToString());
                List[i].FileName       = PIn.PString(table.Rows[i][5].ToString());
                List[i].ImgType        = (ImageType)PIn.PInt(table.Rows[i][6].ToString());
                List[i].IsFlipped      = PIn.PBool(table.Rows[i][7].ToString());
                List[i].DegreesRotated = PIn.PInt(table.Rows[i][8].ToString());
                List[i].ToothNumbers   = PIn.PString(table.Rows[i][9].ToString());
                List[i].Note           = PIn.PString(table.Rows[i][10].ToString());
                List[i].SigIsTopaz     = PIn.PBool(table.Rows[i][11].ToString());
                List[i].Signature      = PIn.PString(table.Rows[i][12].ToString());
            }
            return(List);
        }
Example #7
0
        ///<summary>Only used in FormDefinitions</summary>
        public static Def[] GetCatList(int myCat)
        {
            string command =
                "SELECT * from definition"
                + " WHERE category = '" + myCat + "'"
                + " ORDER BY ItemOrder";
            DataSet ds = null;

            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    ds = GeneralB.GetTable(command);
                }
                else
                {
                    DtoGeneralGetTable dto = new DtoGeneralGetTable();
                    dto.Command = command;
                    ds          = RemotingClient.ProcessQuery(dto);
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
            DataTable table = ds.Tables[0];

            Def[] List = new Def[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i]           = new Def();
                List[i].DefNum    = PIn.PInt(table.Rows[i][0].ToString());
                List[i].Category  = (DefCat)PIn.PInt(table.Rows[i][1].ToString());
                List[i].ItemOrder = PIn.PInt(table.Rows[i][2].ToString());
                List[i].ItemName  = PIn.PString(table.Rows[i][3].ToString());
                List[i].ItemValue = PIn.PString(table.Rows[i][4].ToString());
                List[i].ItemColor = Color.FromArgb(PIn.PInt(table.Rows[i][5].ToString()));
                List[i].IsHidden  = PIn.PBool(table.Rows[i][6].ToString());
            }
            return(List);
        }
Example #8
0
 ///<summary>This is used for queries written by the user.  If using the server component, it uses the user with lower privileges  to prevent injection attack.</summary>
 public static DataTable GetTableLow(string command)
 {
     try {
         DataTable retVal;
         if (RemotingClient.OpenDentBusinessIsLocal)
         {
             retVal = GeneralB.GetTable(command).Tables[0].Copy();
         }
         else
         {
             DtoGeneralGetTableLow dto = new DtoGeneralGetTableLow();
             dto.Command = command;
             retVal      = RemotingClient.ProcessQuery(dto).Tables[0].Copy();
         }
         retVal.TableName = "";              //this is needed for FormQuery dataGrid
         return(retVal);
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
         return(new DataTable());
     }
 }
Example #9
0
        private static Signal[] RefreshAndFill(string command)
        {
            //we don't want an error message to show, because that can cause a cascade of a large number of error messages.
            DataTable table = null;

            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    table = GeneralB.GetTable(command).Tables[0];
                }
                else
                {
                    DtoGeneralGetTable dto = new DtoGeneralGetTable();
                    dto.Command = command;
                    table       = RemotingClient.ProcessQuery(dto).Tables[0];
                }
            }
            catch {
                //MessageBox.Show(e.Message);
                return(new Signal[0]);
            }
            Signal[] List = new Signal[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i]             = new Signal();
                List[i].SignalNum   = PIn.PInt(table.Rows[i][0].ToString());
                List[i].FromUser    = PIn.PString(table.Rows[i][1].ToString());
                List[i].ITypes      = (InvalidTypes)PIn.PInt(table.Rows[i][2].ToString());
                List[i].DateViewing = PIn.PDate(table.Rows[i][3].ToString());
                List[i].SigType     = (SignalType)PIn.PInt(table.Rows[i][4].ToString());
                List[i].SigText     = PIn.PString(table.Rows[i][5].ToString());
                List[i].SigDateTime = PIn.PDateT(table.Rows[i][6].ToString());
                List[i].ToUser      = PIn.PString(table.Rows[i][7].ToString());
                List[i].AckTime     = PIn.PDateT(table.Rows[i][8].ToString());
            }
            Array.Sort(List);
            return(List);
        }
Example #10
0
 ///<summary>We need to get away from this due to poor support from databases.  For now, each command will be sent entirely separately.  This never returns number of rows affected.</summary>
 public static int NonQ(string[] commands)
 {
     try {
         for (int i = 0; i < commands.Length; i++)
         {
             if (RemotingClient.OpenDentBusinessIsLocal)
             {
                 GeneralB.NonQ(commands[i], false);
             }
             else
             {
                 DtoGeneralNonQ dto = new DtoGeneralNonQ();
                 dto.Command     = commands[i];
                 dto.GetInsertID = false;
                 RemotingClient.ProcessCommand(dto);
             }
         }
     }
     catch (Exception e) {
         MessageBox.Show(e.Message);
     }
     return(0);
 }
Example #11
0
        public static void GenerarTicket(int idVenta, int consecutivo, bool preview)
        {
            VentasB  ventBL = new VentasB();
            GeneralB genB   = new GeneralB();

            try
            {
                var    encabezado = ventBL.ConsultaEncabezado(idVenta);
                string printText  =
                    ConfigurationManager.AppSettings["NombreNegocio"].ToUpper() + "\n" +
                    "Cedula: " + ConfigurationManager.AppSettings["Cedula"] + "\n" +
                    "Tel: " + ConfigurationManager.AppSettings["Telefono"] + "\n" +
                    "Fecha: " + encabezado.Fecha.ToShortDateString() + " " + encabezado.Fecha.ToLongTimeString() + "\n" +
                    "Factura: " + consecutivo.ToString() + "\n" +
                    "------------------------------\n" +
                    "ARTICULO                      \n" +
                    " CANT      PRECIO        TOTAL\n" +
                    "------------------------------\n";
                // trae detalle
                string detalleTicket = "";
                //decimal TotalFinal = 0;
                //decimal TotalDescuento = 0;
                //decimal TotalImpuesto = 0;
                decimal TotalFinal     = encabezado.TotalVenta;
                decimal TotalDescuento = encabezado.TotalDescuentos;
                decimal TotalImpuesto  = encabezado.TotalImpuestos;
                var     detalle        = ventBL.ConsultaDetalle(idVenta);
                foreach (var item in detalle)
                {
                    detalleTicket +=
                        (item.Descripcion.Length > 30 ? item.Descripcion.Substring(0, 30) : item.Descripcion.PadRight(30, ' ')) +
                        "\n" +
                        String.Format("{0,5:N0}", item.Cantidad) +
                        String.Format("{0,12:N1}", item.Precio) +
                        String.Format("{0,13:N1}", item.Cantidad * item.Precio) + "\n";
                    //TotalFinal += item.TotalLinea;
                    //TotalDescuento += item.Descuento;
                    //TotalImpuesto += item.Impuesto;
                }
                /// los totales guardados en el encabezado ya tienen el redondeo aplicado
                //detalleTicket +=
                //    "------------------------------\n" +
                //    "Descuento: " + String.Format("{0,19:N1}",
                //        Tools.Redondeo.ApplyRound(TotalDescuento, localRedondeo)) + "\n" +
                //    "Impuestos: " + String.Format("{0,19:N1}",
                //        Tools.Redondeo.ApplyRound(TotalImpuesto, localRedondeo)) + "\n" +
                //    "Total: " + String.Format("{0,23:N1}",
                //        Tools.Redondeo.ApplyRound(TotalFinal, localRedondeo));
                detalleTicket +=
                    "------------------------------\n" +
                    "Descuento: " + String.Format("{0,19:N1}", TotalDescuento) + "\n" +
                    "Impuestos: " + String.Format("{0,19:N1}", TotalImpuesto) + "\n" +
                    "Total: " + String.Format("{0,23:N1}", TotalFinal);
                printText += detalleTicket;
                Printing _printDocument =
                    new Printing(printText);
                if (preview)
                {
                    _printDocument.PrintPreview();
                }
                else
                {
                    _printDocument.Print();
                }
            }
            catch (Exception ex)
            {
                ControlBusiness.BusinessHelpers.General.DoError(ex, "Control", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Example #12
0
        public static int ProcessCommand(DtoCommandBase dto)
        {
            if (dto.GetType() == typeof(DtoDefInsert))
            {
                return(DefB.Insert(((DtoDefInsert)dto).DefCur));
            }
            else if (dto.GetType() == typeof(DtoDefUpdate))
            {
                return(DefB.Update(((DtoDefUpdate)dto).DefCur));
            }
            else if (dto.GetType() == typeof(DtoDocumentInsert))
            {
                return(DocumentB.Insert(((DtoDocumentInsert)dto).Doc, ((DtoDocumentInsert)dto).PatLF, ((DtoDocumentInsert)dto).PatNum));
            }
            else if (dto.GetType() == typeof(DtoDocumentUpdate))
            {
                return(DocumentB.Update(((DtoDocumentUpdate)dto).Doc));
            }
            else if (dto.GetType() == typeof(DtoEmailMessageUpdate))
            {
                return(EmailMessageB.Update(((DtoEmailMessageUpdate)dto).Message));
            }
            else if (dto.GetType() == typeof(DtoGeneralNonQ))
            {
                return(GeneralB.NonQ(((DtoGeneralNonQ)dto).Command, ((DtoGeneralNonQ)dto).GetInsertID));
            }
            else if (dto.GetType() == typeof(DtoLogin))
            {
                return(OpenDentalService.Login(((DtoLogin)dto).Database, ((DtoLogin)dto).OdUser, ((DtoLogin)dto).OdPassHash));
            }
            else if (dto.GetType() == typeof(DtoMiscDataMakeABackup))
            {
                return(MiscDataB.MakeABackup());
            }
            else if (dto.GetType() == typeof(DtoProcedureInsert))
            {
                return(ProcedureB.Insert(((DtoProcedureInsert)dto).Proc));
            }
            else if (dto.GetType() == typeof(DtoProcedureUpdate))
            {
                return(ProcedureB.Update(((DtoProcedureUpdate)dto).Proc, ((DtoProcedureUpdate)dto).OldProc));
            }
            else if (dto.GetType() == typeof(DtoProcedureDelete))
            {
                return(ProcedureB.Delete(((DtoProcedureDelete)dto).ProcNum));
            }
            else if (dto.GetType() == typeof(DtoProcedureUpdateAptNum))
            {
                return(ProcedureB.UpdateAptNum(((DtoProcedureUpdateAptNum)dto).ProcNum, ((DtoProcedureUpdateAptNum)dto).NewAptNum));
            }
            else if (dto.GetType() == typeof(DtoProcedureUpdatePlannedAptNum))
            {
                return(ProcedureB.UpdatePlannedAptNum(((DtoProcedureUpdatePlannedAptNum)dto).ProcNum,
                                                      ((DtoProcedureUpdatePlannedAptNum)dto).NewPlannedAptNum));
            }
            else if (dto.GetType() == typeof(DtoProcedureUpdatePriority))
            {
                return(ProcedureB.UpdatePriority(((DtoProcedureUpdatePriority)dto).ProcNum,
                                                 ((DtoProcedureUpdatePriority)dto).NewPriority));
            }
            else if (dto.GetType() == typeof(DtoProcedureUpdateFee))
            {
                return(ProcedureB.UpdateFee(((DtoProcedureUpdateFee)dto).ProcNum, ((DtoProcedureUpdateFee)dto).NewFee));
            }



            else
            {
                throw new Exception("OpenDentServer.BusinessLayer.ProcessCommand(dto) is missing a case for "
                                    + dto.GetType().ToString());
            }
        }