private void btnWorkSelect_Click(object sender, EventArgs e)
        {
            // ранее введеные значения

            Salary oSalaryExtraWorkTemp = new Salary();

            oSalaryExtraWorkTemp.FilterDateBeg = DateTime.Now.Date.AddYears(-1);
            oSalaryExtraWorkTemp.FilterDateEnd = DateTime.Now.Date;
            oSalaryExtraWorkTemp.FillTableSalaryExtraWorks();
            if (oSalaryExtraWorkTemp.ErrorNumber != 0 || oSalaryExtraWorkTemp.TableSalaryExtraWorks == null)
            {
                return;
            }
            if (oSalaryExtraWorkTemp.TableSalaryExtraWorks.Rows.Count == 0)
            {
                RFMMessage.MessageBoxError("Нет данных...");
                return;
            }

            /*
             * DataTable dtWorkNamesDistinct = new DataTable();
             * dtWorkNamesDistinct.Columns.Add("WorkName");
             * System.Collections.Hashtable hash = new System.Collections.Hashtable();
             * foreach (DataRow row in oSalaryExtraWorkTemp.MainTable.Rows)
             *      hash[row["WorkName"]] = row["WorkName"];
             * foreach (object name in hash.Values)
             *      dtWorkNamesDistinct.Rows.Add(name);
             * DataTable tdWorkNames = CopyTable(dtWorkNamesDistinct, "tdWorkNames", "WorkName > ''", "WorkName");
             */
            DataTable tdWorkNames = new DataView(oSalaryExtraWorkTemp.TableSalaryExtraWorks, "", "WorkName", DataViewRowState.CurrentRows).ToTable(true, "WorkName");

            if (StartForm(new frmSelectID(this, tdWorkNames, "WorkName", "Дополнительная работа", false)) == DialogResult.Yes)
            {
                if (_SelectedID == null)
                {
                    return;
                }
                txtWorkName.Text = _SelectedText;
            }
            _SelectedID   = null;
            _SelectedText = "";

            tabSalaryExtraWorks.IsNeedRestore = true;

            return;
        }
Exemple #2
0
        private void frmSalaryExtraWorksEdit_Load(object sender, EventArgs e)
        {
            bool bResult = true;

            bResult = cboEmployees_Restore();
            if (bResult)
            {
                if (nSalaryExtraWorkID.HasValue)
                {
                    oSalaryExtraWork.nSalaryExtraWorkID = nSalaryExtraWorkID;
                    oSalaryExtraWork.FillTableSalaryExtraWorks();
                    if (oSalaryExtraWork.ErrorNumber != 0 || oSalaryExtraWork.TableSalaryExtraWorks.Rows.Count != 1)
                    {
                        RFMMessage.MessageBoxError("Ошибка при получении данных о дополнительных работах...");
                        bResult = false;
                    }

                    if (bResult)
                    {
                        DataRow r = oSalaryExtraWork.TableSalaryExtraWorks.Rows[0];
                        dtpDateWork.Value          = (DateTime)r["DateWork"];
                        cboEmployees.SelectedValue = (int)r["DriverEmployeeID"];
                        txtWorkName.Text           = r["WorkName"].ToString().Trim();
                        numQnt.Value    = (decimal)r["Qnt"];
                        numTarif.Value  = (decimal)r["Price"];
                        numAmount.Value = Math.Round((decimal)numQnt.Value * (decimal)numTarif.Value, 2);
                        txtNote.Text    = r["Note"].ToString().Trim();
                    }
                }
                else
                {
                    // новый факт выполнения дополнительных работ
                }
            }

            if (!bResult)
            {
                Dispose();
                Close();
            }

            dtpDateWork.Select();
        }
        private bool dgvExtraWorks_Restore()
        {
            RFMCursorWait.Set(true);
            RFMCursorWait.LockWindowUpdate(FindForm().Handle);

            oSalaryExtraWorkList.ClearError();
            oSalaryExtraWorkList.ClearFilters();
            oSalaryExtraWorkList.ID = null;

            // собираем условия

            // даты
            if (!dtrDates.dtpBegDate.IsEmpty)
            {
                oSalaryExtraWorkList.FilterDateBeg = dtrDates.dtpBegDate.Value.Date;
            }
            if (!dtrDates.dtpEndDate.IsEmpty)
            {
                oSalaryExtraWorkList.FilterDateEnd = dtrDates.dtpEndDate.Value.Date;
            }

            if (ucSelectRecordID_DriversEmployees.IsSelectedExist)
            {
                oSalaryExtraWorkList.FilterDriversEmployeesList = ucSelectRecordID_DriversEmployees.GetIdString();
            }

            if (txtWorkName.Text.Trim().Length > 0)
            {
                oSalaryExtraWorkList.FilterWorkNameContext = txtWorkName.Text.Trim();
            }

            dgvExtraWorks.GetGridState();
            oSalaryExtraWorkList.FillTableSalaryExtraWorks();
            dgvExtraWorks.IsLockRowChanged = true;
            dgvExtraWorks.Restore(oSalaryExtraWorkList.TableSalaryExtraWorks);

            RFMCursorWait.LockWindowUpdate(IntPtr.Zero);
            RFMCursorWait.Set(false);

            return(oSalaryExtraWorkList.ErrorNumber == 0);
        }