Example #1
0
        public string HDFamilySize(int hhid)
        {
            string sql = "SELECT RTRIM(case WHEN Infants = 0 THEN '' ELSE CAST(Infants as Varchar(3)) + 'I ' END"
                         + " + case WHEN Youth+Teens+Eighteen = 0 THEN '' ELSE CAST(Youth+Teens+Eighteen as Varchar(3)) + 'C 'END"
                         + " + case WHEN Adults = 0 THEN '' ELSE CAST(Adults as Varchar(3)) + 'A ' END"
                         + " + case WHEN Seniors = 0 THEN '' ELSE CAST(Seniors as Varchar(3)) + 'S' END) FamilySize"
                         + " FROM Household WHERE ServiceMethod = 2 AND ID = " + hhid.ToString();
            object retval = CCFBGlobal.getSQLValue(sql);

            if (retval == null)
            {
                return("");
            }
            else
            {
                return(retval.ToString());
            }
        }
Example #2
0
        private void cboServers_DropDownClosed(object sender, EventArgs e)
        {
            if (cboServers.SelectedItem != null)
            {
                SetVisibility(false);
                CCFBGlobal.setConnectionString(cboServers.SelectedItem.ToString());
            }
            else if (cboServers.Text != null && cboServers.Text != "")
            {
                SetVisibility(false);
                CCFBGlobal.setConnectionString(cboServers.Text);
            }

            if (TestSQLConnection("") == true)
            {
                loadUsers();
            }
        }
Example #3
0
        public bool delete(int key)
        {
            SqlCommand cmdDelete = new SqlCommand(" DELETE FROM HDRSClients WHERE Id=" + key.ToString(), conn);

            try
            {
                openConnection();
                int iRows = cmdDelete.ExecuteNonQuery();
                closeConnection();
                return(iRows == 1);
            }
            catch (SqlException ex)
            {
                CCFBGlobal.appendErrorToErrorReport("Delete Command = " + cmdDelete.CommandText,
                                                    ex.GetBaseException().ToString());
                return(false);
            }
        }
Example #4
0
 public void update()
 {
     try
     {
         openConnection();
         if (dadAdpt.UpdateCommand == null)
         {
             SqlCommandBuilder commBuilder = new SqlCommandBuilder(dadAdpt);
         }
         dadAdpt.Update(dtbl);
         conn.Close();
     }
     catch (SqlException ex)
     {
         CCFBGlobal.appendErrorToErrorReport("Update HDRSClients FAILED ",
                                             ex.GetBaseException().ToString());
     }
 }
 private void lvServiceItems_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (loadingListView == false)
     {
         try
         {
             if (lvServiceItems.SelectedItems.Count > 0)
             {
                 fillForm(Convert.ToInt32(lvServiceItems.SelectedItems[0].SubItems[3].Text));
             }
         }
         catch (Exception ex)
         {
             CCFBGlobal.appendErrorToErrorReport("sender=" + sender.ToString() + "EventArgs=" + e.ToString(),
                                                 ex.GetBaseException().ToString());
         }
     }
 }
Example #6
0
        private void initSchoolComboBox()
        {
            DataGridViewComboBoxColumn colCbo = (DataGridViewComboBoxColumn)dgvHHMembers.Columns["clmSchool"];

            System.Collections.ArrayList newList = new System.Collections.ArrayList(CCFBGlobal.TypeCodesArray(CCFBGlobal.parmTbl_SchSupplySchool));
            if (newList != null && newList.Count > 0)
            {
                colCbo.DataSource    = newList;
                colCbo.DisplayMember = "LongName";
                colCbo.ValueMember   = "UID";
            }
            else
            {
                colCbo.DataSource = null;
                colCbo.Items.Add("Not Initialized");
            }
            //dgvHHMembers.Columns.Add(colCbo);
        }
Example #7
0
        private void getHomeDeliveryClients()
        {
            try
            {
                openConnection();
                dset.Clear();
                dadAdpt.SelectCommand = command;
                rowCount = dadAdpt.Fill(dset, "HomeDeliveryClients");
                closeConnection();
            }
            catch (Exception ex)
            {
                CCFBGlobal.appendErrorToErrorReport("SelectCommand = " + command.CommandText,
                                                    ex.GetBaseException().ToString());
                rowCount = 0;
            }
//            EnableActionMenu();
        }
Example #8
0
 public void openAll()
 {
     try
     {
         openConnection();
         command = new SqlCommand("SELECT * FROM " + tbName, conn);
         dadAdpt.SelectCommand = command;
         dset.Clear();
         iRowCount = dadAdpt.Fill(dset, tbName);
         closeConnection();
     }
     catch (SqlException ex)
     {
         closeConnection();
         CCFBGlobal.appendErrorToErrorReport("", ex.GetBaseException().ToString());
         iRowCount = 0;
     }
 }
Example #9
0
        //private ListViewGroup MakeHouseholdGroup(int hhId, int hhmId)
        //{
        //    Household clsTmpHH = new Household(CCFBGlobal.connectionString);
        //    string hhInfo = "";
        //    ListViewGroup lvg;
        //    clsTmpHH.openWhere("ID = " + hhId);
        //    if (clsTmpHH.RowCount > 0)
        //    {
        //        hhInfo = clsTmpHH.Name + "  " + clsTmpHH.Address + "  " + clsTmpHH.City + ", " + clsTmpHH.State + " " + clsTmpHH.Zipcode
        //               + "  " + CCFBGlobal.IsInactiveString(clsTmpHH.Inactive) + "  " + clsTmpHH.ID.ToString();
        //        lvg = new ListViewGroup(hhInfo, HorizontalAlignment.Left);
        //        lvg.Name = hhId.ToString();
        //    }
        //    else
        //        lvg = new ListViewGroup("HHID = " + hhId.ToString(), HorizontalAlignment.Left);
        //    return lvg;
        //}

        private void tbAge_Leave(object sender, EventArgs e)
        {
            if (tbAge.Text != "" && tbAge.Enabled == true)
            {
                if (chkEnterAge.Checked == true)
                {
                    DateTime birthdate = CCFBGlobal.calcBirthdateFromAge(Convert.ToInt32(tbAge.Text));
                    tbBirthDate.ForeColor = Color.Aqua;
                    tbBirthDate.Text      = birthdate.ToShortDateString();
                    //SetFieldsBasedOnAge(tbAge.Text);
                }
            }
            else if (tbAge.Enabled == true)
            {
                tbAge.Text = "0";
            }
            clearHelpText();
        }
Example #10
0
        }                       // end of EditDonorForm_FormClosing

        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// Read the Type Codes database table and display the data in a DataGridView control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //-----------------------------------------------------------------------------------------
        private void EditDonorForm_Load(object sender, EventArgs e)
        {
            TableName = "Donors";                                                                       // Read from this SQL table.
            //ControlPage			= tpgCompanyInfo.Controls;
            ControlPage        = this.Controls;
            DataGridViewObject = gridEditDonor;
            editDonor_cboRcdType.DataSource    = CCFBGlobal.TypeCodesArray(CCFBGlobal.parmTbl_Donor);
            editDonor_cboRcdType.DisplayMember = "LongName";
            editDonor_cboRcdType.ValueMember   = "UID";

            cboDonationType.DataSource    = CCFBGlobal.TypeCodesArray(CCFBGlobal.parmTbl_Donation);
            cboDonationType.DisplayMember = "LongName";
            cboDonationType.ValueMember   = "UID";
            loadUserFieldLabels();
            SetWhereClause();
            RefreshGrid();
            GridSelectionHandlerEnabled = true;
        }                       // end of EditDonorForm_Load
Example #11
0
 /// <summary>
 /// Loads the DataGrid using values obtained in the DataSet
 /// </summary>
 private void rtplnLoadList(DataRow[] dRows)
 {
     rtplntbFindName.Text = "";
     rtplnLastSearchText  = "";
     rtplndgvHDClientList.Rows.Clear();
     progressBar1.Value = 0;
     progressBar1.Show();
     rtplntbFindName.Visible = rtplncboFilter.Visible = lblFilterBy.Visible = false;
     Application.DoEvents();
     progressBar1.Maximum = dRows.Length;
     for (int i = 0; i < dRows.Length; i++)
     {
         rtplndgvHDClientList.Rows.Add();
         rtplndgvHDClientList["clmCnt", i].Value                   = (i + 1).ToString();
         rtplndgvHDClientList["clmRouteID", i].Value               = true;
         rtplndgvHDClientList["clmRouteID", i].Value               = dRows[i]["HDRoute"];
         rtplndgvHDClientList["clmRouteTitle", i].Value            = dRows[i]["RouteTitle"];
         rtplndgvHDClientList["clmID", i].Value                    = dRows[i]["ID"];
         rtplndgvHDClientList["clmName", i].Value                  = dRows[i]["Name"];
         rtplndgvHDClientList["clmAddress", i].Value               = dRows[i]["Address"].ToString() + "\r\n     " + dRows[i]["City"].ToString() + ", " + dRows[i]["ZipCode"].ToString();
         rtplndgvHDClientList["clmApt", i].Value                   = dRows[i]["AptNbr"];
         rtplndgvHDClientList["clmPhone", i].Value                 = CCFBGlobal.FormatPhone(dRows[i]["Phone"].ToString());
         rtplndgvHDClientList["clmFamilySize", i].Value            = dRows[i]["FamilySize"];
         rtplndgvHDClientList["clmComments", i].Value              = dRows[i]["Comments"];
         rtplndgvHDClientList["clmDriverNotes", i].Value           = dRows[i]["DriverNotes"];
         rtplndgvHDClientList["clmSvcItem", i].Value               = dRows[i]["HDItem"];
         rtplndgvHDClientList["clmLastSvc", i].Value               = CCFBGlobal.ValidDateString(dRows[i]["LatestService"]);
         rtplndgvHDClientList[rtplnSortColName, i].Style.BackColor = Color.Azure;
         progressBar1.PerformStep();
     }
     lblRowCnt.Text = "[ " + rtplndgvHDClientList.Rows.Count.ToString() + " ]";
     rtplnrowIndex  = 0;
     foreach (ToolStripButton tsb in toolStrip2.Items)
     {
         rtplndgvHDClientList.Columns[tsb.Tag.ToString()].Visible = tsb.Checked;
     }
     progressBar1.Value      = 0;
     progressBar1.Visible    = false;
     rtplntbFindName.Visible = true;
     if (rtplnFilterColName != "")
     {
         rtplnGetDistincts(rtplnFilterColName);
     }
 }
Example #12
0
        public void loadDatesList(string minDate, string maxDate)
        {
            sTrxDateMin = minDate;
            sTrxDateMax = maxDate;
            command     = new SqlCommand("Select TrxDate, Sum(NumVolunteers) as NumVols, "
                                         + "Sum(NumVolHours) as NumVolHrs from VolunteerHours Where TrxDate "
                                         + "between '" + minDate.ToString() + "' and '" + maxDate.ToString() + "'"
                                         + "Group By TrxDate Order By TrxDate Desc", conn);

            Single totHours = 0;
            int    totVols  = 0;

            try
            {
                dadAdpt.SelectCommand = command;
                dset.Clear();
                dadAdpt.Fill(dset);
            }
            catch (SqlException ex)
            {
                closeConnection();
                CCFBGlobal.appendErrorToErrorReport("", ex.GetBaseException().ToString(),
                                                    CCFBGlobal.serverName);
            }

            lvDates.Items.Clear();

            ListViewItem lvi;

            for (int i = 0; i < dset.Tables[0].Rows.Count; i++)
            {
                lvi       = new ListViewItem(getFormatedDate(dset.Tables[0].Rows[i]["TrxDate"]));
                totHours += Convert.ToSingle(dset.Tables[0].Rows[i]["NumVolHrs"]);
                totVols  += int.Parse(dset.Tables[0].Rows[i]["NumVols"].ToString());
                lvi.SubItems.Add(dset.Tables[0].Rows[i]["NumVols"].ToString());
                lvi.SubItems.Add(Convert.ToSingle(dset.Tables[0].Rows[i]["NumVolHrs"]).ToString("F"));
                lvDates.Items.Add(lvi);
            }

            dataGridViewVols.Visible = false;
            initVolGroupValues();
            tbNumVols.Text   = totVols.ToString();
            tbTotVolHrs.Text = totHours.ToString("F");
        }
        /// <summary>
        /// Loads the Donor log listView with the donoations for the
        /// Selected donor
        /// </summary>
        private void loadDonorLogList()
        {
            decimal totLbs = 0;
            int     totCnt = 0;

            lvDonorHistory.Items.Clear();
            Application.DoEvents();
            ListViewItem lvItm;

            string donorWhereClause = " WHERE DonorID=" + donorID.ToString();

            switch (cboDonorPeriod.SelectedIndex)
            {
            case 0: donorWhereClause += CCFBGlobal.SQLDateRangeCurMonth();   break;

            case 1: donorWhereClause += CCFBGlobal.SQLDateRangePrevMonth();  break;

            case 2: donorWhereClause += CCFBGlobal.SQLDateRangeLast90Days(); break;

            case 3: donorWhereClause += CCFBGlobal.SQLDateRangeCurYear();    break;

            case 4: donorWhereClause += CCFBGlobal.SQLDateRangePrevYear();   break;

            default: donorWhereClause += DateRangeCustom();                   break;
            }

            clsCashDonations.openWhere(donorWhereClause);

            for (int i = 0; i < clsCashDonations.RowCount; i++)
            {
                clsCashDonations.setDataRow(i);
                lvItm = new ListViewItem((i + 1).ToString());
                lvItm.SubItems.Add(clsCashDonations.TrxDate.ToShortDateString());
                lvItm.SubItems.Add(clsCashDonations.DollarValue.ToString());
                lvItm.SubItems.Add(clsCashDonations.Notes);
                lvItm.SubItems.Add(clsCashDonations.TrxID.ToString());
                lvDonorHistory.Items.Add(lvItm);

                totCnt++;
                totLbs += clsCashDonations.DollarValue;
            }
            tbDonorCnt.Text = totCnt.ToString();
            tbDonorLbs.Text = totLbs.ToString();
        }
Example #14
0
        private void loadList()
        {
            try
            {
                conn.Open();
                command = new SqlCommand("Select v.VoucherItemID, v.Amount, v.Notes, V.trxID "
                                         + "From VoucherLog V Left Join Household H on "
                                         + "V.HouseholdID=H.ID Where H.ID=" + clsClient.clsHH.ID.ToString()
                                         + " And V.trxDate='" + dtpTrxDate.Value.ToShortDateString() + "'", conn);
                reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int id = reader.GetInt32(0);
                        for (int i = 0; i < gridVouchers.Rows.Count; i++)
                        {
                            if (Convert.ToInt32(gridVouchers["clmDesc", i].Tag) == id)
                            {
                                gridVouchers["clmAmount", i].Value   = reader.GetDecimal(1);
                                gridVouchers["clmComments", i].Value = reader.GetValue(2);
                                gridVouchers.Rows[i].Tag             = reader.GetValue(3);

                                if (gridVouchers["clmComments", i].Value == null)
                                {
                                    gridVouchers["clmComments", i].Value = "";
                                }

                                break;
                            }
                        }
                    }
                }


                conn.Close();
            }
            catch (SqlException ex)
            {
                CCFBGlobal.appendErrorToErrorReport("Command Text= " + command.CommandText,
                                                    ex.GetBaseException().ToString(), CCFBGlobal.serverName);
            }
        }
Example #15
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            needtoUpdate   = false;
            SetVisibility(false);
            CCFBGlobal.setConnectionString(ServerNameFromRegistry);

            if (ServerNameFromRegistry == null || String.IsNullOrEmpty(ServerNameFromRegistry) == true)
            {
                loadServers();
                if (CCFBGlobal.sq1ServerName.Length > 0)
                {
                    if (TestSQLConnection("") == true)
                    {
                        loadUsers();
                    }
                }
            }
            else
            {
                if (TestSQLConnection("") == false)
                {
                    loadServers();
                    if (CCFBGlobal.sq1ServerName.Length > 0)
                    {
                        if (TestSQLConnection("") == true)
                        {
                            loadUsers();
                        }
                    }
                }
                else
                if (cboServers.Items.Count == 0)
                {
                    cboServers.Text = ServerNameFromRegistry;
                }

                loadUsers();
            }

            this.ShowInTaskbar = true;
            this.Focus();
            Application.DoEvents();
        }
Example #16
0
        }                       // end of property DbRowCount


        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// Save the DataSet data to the database.
        /// </summary>
        /// <param name="a_save">TRUE = save DB updates, FALSE=close without saving.</param>
        //-----------------------------------------------------------------------------------------
        public void DbSave()
        {
            try
            {
                if (m_sqlAdapter.UpdateCommand == null)
                {
                    // When the DataSet is working with a single table then the SqlCommandBuilder
                    // will create the INSERT, DELETE, and UPDATE commands to update the DataSet
                    // to the SQL database.
                    SqlCommandBuilder sqlCommandBuilder = new SqlCommandBuilder(m_sqlAdapter);
                    sqlCommandBuilder.GetUpdateCommand();
                }
                m_sqlAdapter.Update(m_dataSet, TableName);      // Update DataSet data to SQL database.
            }
            catch (Exception ex)
            {
                CCFBGlobal.appendErrorToErrorReport("", ex.GetBaseException().ToString());
            }
        }                       // end of DbSave
        private void loadList()
        {
            ListViewItem lvi2;
            DataRow      drow;

            for (int i = 0; i < clsClient.clsHHmem.RowCount; i++)
            {
                drow = clsClient.clsHHmem.DSet.Tables[0].Rows[i];
                if (drow.RowState != DataRowState.Deleted)
                {
                    //Create New item
                    lvi2 = new ListViewItem(drow["LastName"].ToString() + ", " + drow["FirstName"].ToString());

                    //Load subitems
                    lvi2.SubItems.Add(drow["Age"].ToString());
                    lvi2.SubItems.Add(CCFBGlobal.ValidDateString(drow["Birthdate"]));
                    lvi2.SubItems.Add(drow["ID"].ToString());
                    if ((bool)drow["CSFP"] == true)
                    {
                        lvi2.Checked = true;
                        lvi2.SubItems.Add(CCFBGlobal.ValidDateString(drow["CSFPExpiration"]));
                        lvi2.ForeColor = Color.DarkBlue;
                    }
                    else
                    {
                        lvi2.SubItems.Add("");
                    }

                    // Add Item to the list items
                    lvHHMems.Items.Add(lvi2);
                }
            }
            if (lvHHMems.Items.Count > 0)
            {
                lvHHMems.Items[0].Focused = true;
            }
            else
            {
                btnSave.Enabled      = false;
                tbExpireDate.Visible = false;
                label5.Visible       = false;
            }
        }
Example #18
0
        //private void copy()
        //{
        //    try
        //    {
        //        File.Copy(fileSource, fileDestination, true);
        //        MessageBox.Show("Backup Complete. File Saved To " + fileDestination);
        //    }
        //    catch (Exception ex)
        //    {
        //        CCFBGlobal.appendErrorToErrorReport("Copy " + fileSource + " to " + fileDestination, ex.GetBaseException().ToString());
        //        MessageBox.Show("Could Not Copy File\r\nFrom: " + fileSource + "\r\n  To: " + fileDestination,
        //            "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //    }
        //}

        private string getBackupPath(string oriPath)
        {
            try
            {
                //Set default extension of the savefile dialog
                saveFileDialog1.DefaultExt = "bak";
                //If no value exists in registry for default save location
                if (oriPath == "")
                {
                    FileInfo fi = new FileInfo(Application.ExecutablePath);

                    //Get all drives on computer
                    DriveInfo[] drives = DriveInfo.GetDrives();

                    //Travers drives in reverse looking for a removeable drive with enough space on it for the backup file
                    for (int i = drives.Length - 1; i >= 0; i--)
                    {
                        if (drives[i].DriveType == DriveType.Removable && drives[i].AvailableFreeSpace > fi.Length)
                        {
                            oriPath = drives[i].Name;
                            break;
                        }
                    }
                }
                saveFileDialog1.InitialDirectory = Path.GetDirectoryName(oriPath);
                saveFileDialog1.FileName         = sqlBackupFile;
                saveFileDialog1.Filter           = "SQL Backup Files (*.bak)|*.bak";
                DialogResult dr = saveFileDialog1.ShowDialog();

                //If user confirmed save
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    //Set the value of the path in the registry
                    Registry.SetValue(CCFBGlobal.registryKeyCurrentUser, CCFBGlobal.regsubkeySavePath, saveFileDialog1.FileName);
                    return(saveFileDialog1.FileName);
                }
            }
            catch (Exception ex)
            {
                CCFBGlobal.appendErrorToErrorReport("", ex.GetBaseException().ToString());
            }
            return(oriPath);
        }
Example #19
0
 public void getDistincts(string columnName)
 {
     try
     {
         openConnection();
         command = new SqlCommand("SELECT Distinct " + columnName + " FROM " + tbName
                                  + " a WHERE DateRangeType >= 0 Order By a." + columnName, conn);
         dadAdpt.SelectCommand = command;
         dset.Clear();
         iRowCount = dadAdpt.Fill(dset, tbName);
         closeConnection();
     }
     catch (SqlException ex)
     {
         CCFBGlobal.appendErrorToErrorReport("key=" + ID.ToString(), ex.GetBaseException().ToString());
         closeConnection();
         iRowCount = 0;
     }
 }
Example #20
0
        private void dataGridViewUsers_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int rowIndex = dataGridViewUsers.CurrentRow.Index;

            if (dataGridViewUsers.CurrentRow.Cells["clmId"].Value != null)
            {
                clsUsers.SetDataValue(rowIndex, "UserRole", dataGridViewUsers.CurrentRow.Cells[1].Value.ToString());

                clsUsers.SetDataValue(rowIndex, "UserName", dataGridViewUsers.CurrentRow.Cells[0].Value.ToString());

                clsUsers.update();
            }
            else
            {
                switch (e.ColumnIndex)
                {
                case 0:
                {
                    newUserName = CCFBGlobal.NullToBlank(dataGridViewUsers.Rows[rowIndex].Cells[0].Value);
                    if (newUserName == "")
                    {
                        if (MessageBox.Show("Do you want me to delete this row?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            dataGridViewUsers.Rows.RemoveAt(rowIndex);
                        }
                    }
                    dataGridViewUsers.Rows[rowIndex].Cells[1].Value = CCFBGlobal.nameUserRole_Intake;
                    break;
                }

                default:
                {
                    newUserRole = dataGridViewUsers.Rows[rowIndex].Cells[1].GetEditedFormattedValue
                                      (rowIndex, DataGridViewDataErrorContexts.LeaveControl).ToString();
                    break;
                }
                }
                pannelPassword.Visible = true;
                btnSetPassword.Visible = false;
                btnDelete.Enabled      = false;
                tbPassword1.Focus();
            }
        }
Example #21
0
 private void btnPost_Click(object sender, EventArgs e)
 {
     try
     {
         conn.Open();
         command = new SqlCommand("Update VoucherLog Set Infants= " + tbInfants.Text + ", Youth= "
                                  + tbYouth.Text + ", Teens=" + tbTeens.Text + ", " + "Eighteen=0, Adults=" + tbAdults.Text
                                  + ", Seniors=" + tbSeniors.Text + ", TotalFamily=" + tbTotalFam.Text + ", Disabled="
                                  + tbDisabled.Text + " Where TrxDate = '" + dtpTrxDate.Value.ToShortDateString() + "' And "
                                  + "HouseholdID = " + curHHID.ToString(), conn);
         command.ExecuteNonQuery();
         conn.Close();
     }
     catch (System.Exception ex)
     {
         CCFBGlobal.appendErrorToErrorReport("Command Text = " + command.CommandText,
                                             ex.GetBaseException().ToString());
     }
 }
        /// <summary>
        /// Commits all changes in the dataset to the Donations table
        /// </summary>
        private void update()
        {
            if (dset.HasChanges())
            {
                try
                {
                    if (dadAdpt.UpdateCommand == null || dadAdpt.InsertCommand == null || dadAdpt.DeleteCommand == null)
                    {
                        SqlCommandBuilder commBuilder = new SqlCommandBuilder(dadAdpt);
                    }

                    dadAdpt.Update(dset);
                }
                catch (SqlException ex)
                {
                    CCFBGlobal.appendErrorToErrorReport("", ex.GetBaseException().ToString());
                }
            }
        }
Example #23
0
 private void rtplnGetHomeDeliveryClients()
 {
     try
     {
         openConnection();
         rtplnDTbl.Clear();
         rtplnDadAdpt.SelectCommand = rtplnSqlCmd;
         rtplnRowCount = rtplnDadAdpt.Fill(rtplnDTbl);
         closeConnection();
         rtplnLoadList(rtplnDTbl.Select());
     }
     catch (Exception ex)
     {
         CCFBGlobal.appendErrorToErrorReport("SelectCommand = " + rtplnSqlCmd.CommandText,
                                             ex.GetBaseException().ToString());
         rtplnRowCount = 0;
     }
     //            EnableActionMenu();
 }
Example #24
0
        public void insert()
        {
            if (dadAdpt.UpdateCommand == null || dadAdpt.InsertCommand == null)
            {
                SqlCommandBuilder commBuilder = new SqlCommandBuilder(dadAdpt);
            }

            try
            {
                openConnection();
                dadAdpt.Update(dset, tbName);
                closeConnection();
            }
            catch (SqlException ex)
            {
                CCFBGlobal.appendErrorToErrorReport("", ex.GetBaseException().ToString(),
                                                    CCFBGlobal.serverName);
            }
        }
Example #25
0
 public VoucherShortForm(Client clsClientIn)
 {
     InitializeComponent();
     clsHH   = clsClientIn.clsHH;
     curHHID = clsHH.ID;
     //tbClient.Text = curHHID.ToString() + Environment.NewLine + clsHH.Name;
     mnuHHName.Text        = "[" + curHHID.ToString() + "] " + clsHH.Name;
     clsVItems             = new VoucherItems(CCFBGlobal.connectionString);
     clsVoucher            = new VoucherLog(SQLConn);
     clsVoucherExisitsTest = new VoucherLog(SQLConn);
     CCFBGlobal.InitCombo(cboHHCat, CCFBGlobal.parmTbl_Client);
     dtpTrxDate.Value    = dtDefault;
     pnlEditVLog.Visible = false;
     pnlBtns.Visible     = true;
     pnlBtns.Dock        = DockStyle.Fill;
     loadVItmsList();
     cboVHistoryPeriod.SelectedIndex = 2;
     cboVHistoryPeriod_SelectionChangeCommitted(cboVHistoryPeriod, EventArgs.Empty);
 }
Example #26
0
 public object GetDataValue(string FieldName, int rowIndex)
 {
     try
     {
         if (dset.Tables[tbName].Columns.Contains(FieldName) == true)
         {
             return(dset.Tables[tbName].Rows[rowIndex][FieldName]);
         }
         else
         {
             return("");
         }
     }
     catch (IndexOutOfRangeException ex)
     {
         CCFBGlobal.appendErrorToErrorReport("FieldName=" + FieldName, ex.GetBaseException().ToString());
         return("");
     }
 }
Example #27
0
 //Gets property through use of just the collum name in database
 public bool GetDataValueBool(string FieldName)
 {
     try
     {
         if (dset.Tables[tbName].Columns.Contains(FieldName) == true)
         {
             return(Convert.ToBoolean(drow[FieldName]));
         }
         else
         {
             return(false);
         }
     }
     catch (IndexOutOfRangeException ex)
     {
         CCFBGlobal.appendErrorToErrorReport("FieldName=" + FieldName, ex.GetBaseException().ToString());
         return(false);
     }
 }
Example #28
0
 private void tbBarCode_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Return)
     {
         if (tbBarCode.Text != "")
         {
             selectedhhid = CCFBGlobal.getClientFromBarCode(tbBarCode.Text.ToString());
             if (selectedhhid != 0)
             {
                 frmMain.setHousehold(selectedhhid, 0);
                 this.Visible = false;
             }
             else
             {
                 MessageBox.Show("This barcode is not in the database", "Barcode Search", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
         }
     }
 }
Example #29
0
 public object GetDataValue(string FieldName, int rowIndex)
 {
     try
     {
         return(dset.Tables[tbName].Rows[rowIndex][FieldName]);
     }
     catch (IndexOutOfRangeException ex)
     {
         CCFBGlobal.appendErrorToErrorReport("FieldName=" + FieldName + ", rowIndex=" + rowIndex.ToString(),
                                             ex.GetBaseException().ToString());
         return("");
     }
     catch (NullReferenceException ex)
     {
         CCFBGlobal.appendErrorToErrorReport("FieldName=" + FieldName + ", rowIndex=" + rowIndex.ToString(),
                                             ex.GetBaseException().ToString());
         return("");
     }
 }
        /// <summary>
        /// Retrives the Donation Data by week totals and loads them into the MonthTotals grid
        /// </summary>
        private void getAndLoadByWeekData()
        {
            dgvMonthReceipts.Columns[0].HeaderText = "Food Classes - " + cboReportMonth.SelectedItem.ToString()
                                                     + "/" + cboYear.SelectedItem.ToString();
            commandByWeek.Parameters[0].Value = dateStart.ToString();
            commandByWeek.Parameters[1].Value = dateEnd.ToString();
            commandByWeek.Parameters[2].Value = Convert.ToInt32(cboStore.SelectedValue);
            try
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                SqlDataReader reader = commandByWeek.ExecuteReader();

                while (reader.Read())
                {
                    int icol = Convert.ToInt32(reader.GetValue(0));
                    int irow = findRowInGridFromFoodClass(Convert.ToInt32(reader.GetValue(1)));
                    dgvMonthTotals[icol, irow].Value = CCFBGlobal.formatNumberWithCommas(reader.GetValue(2));
                }

                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                CCFBGlobal.appendErrorToErrorReport("", ex.GetBaseException().ToString());
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }