public void UpdateActive()
 {
     if (ceamantvisa.Checked && Convert.ToInt32(lueDofatSarfAId.EditValue) > 6)// we should it acc reviewed if this condition active
     {
         int result1 = new DataSources.dsQueriesTableAdapters.QueriesTableAdapter().Update_TblWarasa_Active_yasref_byVisa_ForAmanat(_row.PersonId, Program.UserInfo.UserId);
     }
 }
 public void UpdateActive()
 {
     DataSources.dsRetirementCenter.TBLMashatDataTable tbl = new DataSources.dsRetirementCenter.TBLMashatDataTable();
     DataSources.dsRetirementCenterTableAdapters.TBLMashatTableAdapter adp = new DataSources.dsRetirementCenterTableAdapters.TBLMashatTableAdapter();
     adp.FillByMMashatId(tbl, _row.MMashatId);
     if (ceamantvisa.Checked && Convert.ToInt32(lueDofatSarfAId.EditValue) > 6 && tbl[0].MashHalaId == (byte)Program.CDMashHala.Asda2)// we should it acc reviewed if this condition active
     {
         int result1 = new DataSources.dsQueriesTableAdapters.QueriesTableAdapter().Update_TblMashat_Active_yasref_byID_ForAmanat(_row.MMashatId, Program.UserInfo.UserId);
     }
 }
 private void repositoryItemButtonEditSave_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     GridView GV = (GridView)gridControlData.MainView;
     DataSources.dsRetirementCenter.TblMemberAmanatRow row = (DataSources.dsRetirementCenter.TblMemberAmanatRow)GV.GetFocusedDataRow();
     row.useracc = Program.UserInfo.UserId;
     row.EndEdit();
     if (row["cheekno", DataRowVersion.Original] != row["cheekno", DataRowVersion.Current])
     {
         if (!row.IstasleemdateNull())
         {
             msgDlg.Show("لا يمكن تعديل رقم الشيك لهذا الحقل ذلك للاعتبارات التالية" + Environment.NewLine + "تم التسليم", msgDlg.msgButtons.Close);
             return;
         }
         row.userincheek = Program.UserInfo.UserId;
         row.datincheek = SQLProvider.ServerDateTime();
     }
     string orgAccCheck = row["accReview", DataRowVersion.Original] == null ? string.Empty : row["accReview", DataRowVersion.Original].ToString();
     string curAccCheck = row["accReview", DataRowVersion.Current] == null ? string.Empty : row["accReview", DataRowVersion.Current].ToString();
     if (orgAccCheck != curAccCheck)
     {
         row.useracc = Program.UserInfo.UserId;
         row.dateReview = SQLProvider.ServerDateTime();
     }
     row.EndEdit();
     tblMemberAmanatTableAdapter.Update(row);
     //ReActive any Person with same visa as current Person
     if (row.accReview)
     {
         int result1 = new DataSources.dsQueriesTableAdapters.QueriesTableAdapter().Update_TblMashat_Active_yasref_byID_ForAmanat(row.MMashatId, Program.UserInfo.UserId);
     }
     msgDlg.Show("تم حفظ التعديل", msgDlg.msgButtons.Close);
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            AddEventHandlerToDataChange(false);
            if (!dxValidationProviderMain.Validate())
                return;
            if (ceEnableEdafat.Checked)
            {
                if (!dxValidationProviderEdafat.Validate())
                    return;
            }
            _TBLWarasa[0].EndEdit();
            if (!_TBLWarasa[0].IspersonNIDNull() && _TBLWarasa[0].personNID.ToString() != string.Empty && _TBLWarasa[0].personNID.Length != 14)
            {
                msgDlg.Show("الرقم القومي يجب ان يكون 14 رقم");
                return;
            }

            if (_TBLWarasa.Rows[0].RowState == DataRowState.Added)
            {
                ((DataSources.dsRetirementCenter.TBLWarasaRow)_TBLWarasa.Rows[0]).PersonId = (int)SQLProvider.adpQry.TBLWarasaNewId();
                //Must Type NID
                if ((tbpersonNID.EditValue == null || tbpersonNID.EditValue.ToString() == string.Empty) && luenationaltyId.EditValue.ToString() == "1")
                {
                    Program.ShowMsg("يجب ادخال الرقم القومي", true, this, true);
                    return;
                }
            }
            else
            {
                //check if user remove responsiblesarf from this person and this person is responsiblesarf to other
                if ((_TBLWarasa[0]["responsiblesarf", DataRowVersion.Current].ToString() != _TBLWarasa[0]["responsiblesarf", DataRowVersion.Original].ToString()) && !_TBLWarasa[0].responsiblesarf)
                {
                    if (SQLProvider.adpQry.TBLWarasaPersonResponsibleSarfCount(_TBLWarasa[0].PersonId) > 0)
                    {
                        Program.ShowMsg("لا يمكن ازالة مسؤل الصرف عن هذا الوريث لانه مسئول صرف عن اخرين" + Environment.NewLine +
                        "قم بأزالة مسئوليته عن الاخرين ثم عاود التعديل", true, this, true);
                        return;
                    }
                    if (_TBLWarasa[0].responsiblesarfId == _TBLWarasa[0].PersonId)
                    {
                        Program.ShowMsg("مسئول الصرف يجب ان يكون مسئول", true, this, true);
                        return;
                    }
                }
                if (_TBLWarasa[0].yasref && !_TBLWarasa[0].responsiblesarf)
                {
                    if (_TBLWarasa[0].responsiblesarfId == _TBLWarasa[0].PersonId)
                    {
                        Program.ShowMsg("مسئول الصرف يجب ان يكون مسئول", true, this, true);
                        return;
                    }
                    object ResIsRes = new DataSources.dsQueriesTableAdapters.QueriesTableAdapter().GetResponsiblesarfByPersonId(_TBLWarasa[0].responsiblesarfId);
                    if (ResIsRes == null || !(bool)ResIsRes)
                    {
                        Program.ShowMsg("مسئول الصرف يجب ان يكون مسئول", true, this, true);
                        return;
                    }
                }

            }
            if (ceresponsiblesarf.Checked)
                ((DataSources.dsRetirementCenter.TBLWarasaRow)_TBLWarasa.Rows[0]).responsiblesarfId = ((DataSources.dsRetirementCenter.TBLWarasaRow)_TBLWarasa.Rows[0]).PersonId;

            if (tbpersonNID.EditValue != null && tbpersonNID.EditValue.ToString() != string.Empty)
            {
                if ((int)SQLProvider.adpQry.ExistsNID(tbpersonNID.EditValue.ToString(), -100, ((DataSources.dsRetirementCenter.TBLWarasaRow)_TBLWarasa.Rows[0]).PersonId) > 0)
                {
                    Program.ShowMsg("الرقم القومي موجود مسبقا", true, this, true);
                    return;
                }
                if (_TBLWarasa.Rows[0].RowState != DataRowState.Added)
                {
                    if ((_TBLWarasa[0]["personNID", DataRowVersion.Current].ToString() != _TBLWarasa[0]["personNID", DataRowVersion.Original].ToString()))
                        _TBLWarasa[0].ImportDateIn = SQLProvider.ServerDateTime();
                }
            }
            DataSources.dsRetirementCenter.TBLWarasaRow myrow = (DataSources.dsRetirementCenter.TBLWarasaRow)_TBLWarasa.Rows[0];
            if (!myrow.IspersonNIDNull() && myrow.personNID != string.Empty)
            {
                try
                {
                    myrow.personbirth = Convert.ToDateTime(Misc.Misc.IDExtraction(myrow.personNID)[1]);
                }
                catch (Exception ex)
                {
                    Program.ShowMsg("خطاء في الرقم القومي" + Environment.NewLine + ex.Message, true, this, true);
                    Program.Logger.LogThis("خطاء في الرقم القومي" + Environment.NewLine + ex.Message, Text, FXFW.Logger.OpType.fail, null, null, this);
                    return;
                }
            }
            //check if responsiblesarfId and his dependances have same visa
            if (_TBLWarasa[0].responsiblesarf && !_TBLWarasa[0].IsvisaNull())
            {
                if ((bool)FXFW.SqlDB.LoadDataTable(string.Format("SELECT CASE WHEN EXISTS(SELECT * FROM TBLWarasa WHERE responsiblesarfId = {0} AND visa IS NOT NULL AND visa <> '{1}') THEN CAST(0 AS bit) ELSE CAST(1 AS bit) END AS OK", _TBLWarasa[0].PersonId, _TBLWarasa[0].visa)).Rows[0][0] == false)
                {
                    Program.ShowMsg("رقم الفيزا للتابعين مختلف عن رقم الفيزا للمسئول", true, this, true);
                    Program.Logger.LogThis("رقم الفيزا للتابعين مختلف عن رقم الفيزا للمسئول", Text, FXFW.Logger.OpType.fail, null, null, this);
                    return;
                }
            }
            if (!_TBLWarasa[0].responsiblesarf && _TBLWarasa[0].responsiblesarfId != _TBLWarasa[0].PersonId && !_TBLWarasa[0].IsvisaNull())
            {
                DataTable visaTbl = FXFW.SqlDB.LoadDataTable("SELECT visa FROM TBLWarasa WHERE PersonId = " + _TBLWarasa[0].responsiblesarfId);
                if (visaTbl.Rows[0][0].ToString() != _TBLWarasa[0].visa)
                {
                    Program.ShowMsg("رقم الفيزا مختلف عن رقم الفيزا للمسئول", true, this, true);
                    Program.Logger.LogThis("رقم الفيزا مختلف عن رقم الفيزا للمسئول", Text, FXFW.Logger.OpType.fail, null, null, this);
                    return;
                }
            }
            //DataTable visaTbl = FXFW.SqlDB.LoadDataTable("SELECT visa FROM TBLWarasa WHERE PersonId = " + )

            foreach (DataSources.dsRetirementCenter.TBLNoSarfWarsaRow row in _TBLNoSarfWarsa.Rows)
            {
                row.PersonId = ((DataSources.dsRetirementCenter.TBLWarasaRow)_TBLWarasa.Rows[0]).PersonId;
            }
            foreach (DataSources.dsRetirementCenter.tblvisawarsaactiveRow row in _tblvisawarsaactive.Rows)
            {
                row.PersonId = ((DataSources.dsRetirementCenter.TBLWarasaRow)_TBLWarasa.Rows[0]).PersonId;
            }
            if (ceEnableEdafat.Checked)
            {
                foreach (DataSources.dsRetirementCenter.TBLEdafatWarsaRow row in _TBLEdafatWarsa.Rows)
                {
                    row.PersonId = ((DataSources.dsRetirementCenter.TBLWarasaRow)_TBLWarasa.Rows[0]).PersonId;
                }
            }
            else
                _TBLEdafatWarsa.Clear();

            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Ejemplo n.º 5
0
        private static bool CheckExpiration()
        {
            DateTime periodDate = new DateTime(2014, 8, 17);
            bool ReturnMe = false;
            DataSources.dsQueries ds = new DataSources.dsQueries();
            DataSources.dsQueriesTableAdapters.QueriesTableAdapter adpQry = new DataSources.dsQueriesTableAdapters.QueriesTableAdapter();

            if (periodDate > SQLProvider.ServerDateTime())
            {
                adpQry.UpdateQueryStartAuth();
                return true;
            }

            try
            {
                ReturnMe = (bool)adpQry.ScalarQueryAuth();
                if (ReturnMe)
                {
                    if (DateTime.Compare(periodDate, (DateTime)adpQry.ServerDateTime()) != 1)
                    {
                        ReturnMe = false;
                        adpQry.UpdateQueryEndAuth();
                    }
                }
            }
            catch { }
            return ReturnMe;

        }