예제 #1
0
        ///<summary>Inserts one EClipboardSheetDef into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(EClipboardSheetDef eClipboardSheetDef, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO eclipboardsheetdef (";

            if (!useExistingPK && isRandomKeys)
            {
                eClipboardSheetDef.EClipboardSheetDefNum = ReplicationServers.GetKeyNoCache("eclipboardsheetdef", "EClipboardSheetDefNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EClipboardSheetDefNum,";
            }
            command += "SheetDefNum,ClinicNum,ResubmitInterval,ItemOrder) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(eClipboardSheetDef.EClipboardSheetDefNum) + ",";
            }
            command +=
                POut.Long(eClipboardSheetDef.SheetDefNum) + ","
                + POut.Long(eClipboardSheetDef.ClinicNum) + ","
                + "'" + POut.Long(eClipboardSheetDef.ResubmitInterval.Ticks) + "',"
                + POut.Int(eClipboardSheetDef.ItemOrder) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                eClipboardSheetDef.EClipboardSheetDefNum = Db.NonQ(command, true, "EClipboardSheetDefNum", "eClipboardSheetDef");
            }
            return(eClipboardSheetDef.EClipboardSheetDefNum);
        }
        private void SwapSheets(bool moveUp)
        {
            if (gridEClipboardSheetsInUse.SelectedIndices.Count() == 0)
            {
                return;
            }
            int selectedIdx = gridEClipboardSheetsInUse.GetSelectedIndex();

            if (moveUp && selectedIdx == 0)
            {
                return;
            }
            if (!moveUp && selectedIdx == gridEClipboardSheetsInUse.ListGridRows.Count - 1)
            {
                return;
            }
            int swapIdx = selectedIdx + (moveUp?-1:1);
            EClipboardSheetDef selectedSheet = (EClipboardSheetDef)gridEClipboardSheetsInUse.ListGridRows[selectedIdx].Tag;
            EClipboardSheetDef swapSheet     = (EClipboardSheetDef)gridEClipboardSheetsInUse.ListGridRows[swapIdx].Tag;
            int selectedItemOrder            = selectedSheet.ItemOrder;

            selectedSheet.ItemOrder = swapSheet.ItemOrder;
            swapSheet.ItemOrder     = selectedItemOrder;
            FillGridEClipboardSheetInUse();
            gridEClipboardSheetsInUse.SetSelected(swapIdx, setValue: true);
        }
예제 #3
0
        ///<summary>Updates one EClipboardSheetDef in the database.</summary>
        public static void Update(EClipboardSheetDef eClipboardSheetDef)
        {
            string command = "UPDATE eclipboardsheetdef SET "
                             + "SheetDefNum          =  " + POut.Long(eClipboardSheetDef.SheetDefNum) + ", "
                             + "ClinicNum            =  " + POut.Long(eClipboardSheetDef.ClinicNum) + ", "
                             + "ResubmitInterval     =  " + POut.Long(eClipboardSheetDef.ResubmitInterval.Ticks) + ", "
                             + "ItemOrder            =  " + POut.Int(eClipboardSheetDef.ItemOrder) + " "
                             + "WHERE EClipboardSheetDefNum = " + POut.Long(eClipboardSheetDef.EClipboardSheetDefNum);

            Db.NonQ(command);
        }
예제 #4
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EClipboardSheetDef> TableToList(DataTable table)
        {
            List <EClipboardSheetDef> retVal = new List <EClipboardSheetDef>();
            EClipboardSheetDef        eClipboardSheetDef;

            foreach (DataRow row in table.Rows)
            {
                eClipboardSheetDef = new EClipboardSheetDef();
                eClipboardSheetDef.EClipboardSheetDefNum = PIn.Long(row["EClipboardSheetDefNum"].ToString());
                eClipboardSheetDef.SheetDefNum           = PIn.Long(row["SheetDefNum"].ToString());
                eClipboardSheetDef.ClinicNum             = PIn.Long(row["ClinicNum"].ToString());
                eClipboardSheetDef.ResubmitInterval      = TimeSpan.FromTicks(PIn.Long(row["ResubmitInterval"].ToString()));
                eClipboardSheetDef.ItemOrder             = PIn.Int(row["ItemOrder"].ToString());
                retVal.Add(eClipboardSheetDef);
            }
            return(retVal);
        }
        private void GridEClipboardSheetsInUse_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            EClipboardSheetDef eSheet = (EClipboardSheetDef)gridEClipboardSheetsInUse.ListGridRows[e.Row].Tag;
            InputBox           input  = new InputBox("How often should the patient be asked to resubmit this form? (In days, where 0 indicates never.)", eSheet.ResubmitInterval.TotalDays.ToString());

            if (input.ShowDialog() == DialogResult.OK)
            {
                int days;
                if (!int.TryParse(input.textResult.Text, out days))
                {
                    MsgBox.Show("Input must be a valid whole number");
                    return;
                }
                eSheet.ResubmitInterval = TimeSpan.FromDays(days);
            }
            FillGridEClipboardSheetInUse();
        }
예제 #6
0
        ///<summary>Updates one EClipboardSheetDef in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(EClipboardSheetDef eClipboardSheetDef, EClipboardSheetDef oldEClipboardSheetDef)
        {
            string command = "";

            if (eClipboardSheetDef.SheetDefNum != oldEClipboardSheetDef.SheetDefNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SheetDefNum = " + POut.Long(eClipboardSheetDef.SheetDefNum) + "";
            }
            if (eClipboardSheetDef.ClinicNum != oldEClipboardSheetDef.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(eClipboardSheetDef.ClinicNum) + "";
            }
            if (eClipboardSheetDef.ResubmitInterval != oldEClipboardSheetDef.ResubmitInterval)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ResubmitInterval = '" + POut.Long(eClipboardSheetDef.ResubmitInterval.Ticks) + "'";
            }
            if (eClipboardSheetDef.ItemOrder != oldEClipboardSheetDef.ItemOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ItemOrder = " + POut.Int(eClipboardSheetDef.ItemOrder) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE eclipboardsheetdef SET " + command
                      + " WHERE EClipboardSheetDefNum = " + POut.Long(eClipboardSheetDef.EClipboardSheetDefNum);
            Db.NonQ(command);
            return(true);
        }
예제 #7
0
 ///<summary>Returns true if Update(EClipboardSheetDef,EClipboardSheetDef) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(EClipboardSheetDef eClipboardSheetDef, EClipboardSheetDef oldEClipboardSheetDef)
 {
     if (eClipboardSheetDef.SheetDefNum != oldEClipboardSheetDef.SheetDefNum)
     {
         return(true);
     }
     if (eClipboardSheetDef.ClinicNum != oldEClipboardSheetDef.ClinicNum)
     {
         return(true);
     }
     if (eClipboardSheetDef.ResubmitInterval != oldEClipboardSheetDef.ResubmitInterval)
     {
         return(true);
     }
     if (eClipboardSheetDef.ItemOrder != oldEClipboardSheetDef.ItemOrder)
     {
         return(true);
     }
     return(false);
 }
 private void ButEClipboardRight_Click(object sender, EventArgs e)
 {
     if (listEClipboardSheetsAvailable.SelectedItems.Count == 0)
     {
         return;
     }
     foreach (SheetDef sheetCur in listEClipboardSheetsAvailable.SelectedItems.Cast <ODBoxItem <SheetDef> >().Select(x => x.Tag))
     {
         EClipboardSheetDef eSheet = _listEClipboardSheets.FirstOrDefault(x => x.ClinicNum == _clinicNumEClipboardTab && x.SheetDefNum == sheetCur.SheetDefNum);
         if (eSheet == null)
         {
             eSheet = new EClipboardSheetDef()
             {
                 SheetDefNum      = sheetCur.SheetDefNum,
                 ClinicNum        = _clinicNumEClipboardTab,
                 ResubmitInterval = TimeSpan.FromDays(30),
             };
             _listEClipboardSheets.Add(eSheet);
         }
     }
     FillGridEClipboardSheetInUse();
     SetEClipboardSheetOrder();
 }
예제 #9
0
 ///<summary>Inserts one EClipboardSheetDef into the database.  Returns the new priKey.</summary>
 public static long Insert(EClipboardSheetDef eClipboardSheetDef)
 {
     return(Insert(eClipboardSheetDef, false));
 }