private void HoldyGridView_CommandCellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { var col = HoldyGridView.CurrentColumn.Index; if (col == 4) { EditHoldyFrm frm = new EditHoldyFrm(); HoldyTable tb = (HoldyTable)HoldyGridView.CurrentRow.DataBoundItem; frm.Htb = tb; frm.ShowDialog(); } if (col == 5) { if (RadMessageBox.Show(this, "هل تريد حذف السجل", "حذف السجلات", MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes) { if (HoldyCmd.DeleteHoldy(((HoldyTable)this.HoldyGridView.CurrentRow.DataBoundItem).Id)) { } else { RadMessageBox.Show("لا يمكن حذف السجل", "خطأ", MessageBoxButtons.OK, RadMessageIcon.Error); } } } }
private void SaveBtn_Click(object sender, EventArgs e) { #region " CheckFillTextBox " if (HoldyTypeDropDownList.Text == "") { HoldyTypeDropDownList.BackColor = Color.OrangeRed; HoldyTypeDropDownList.Focus(); return; } else { HoldyTypeDropDownList.BackColor = Color.White; } #endregion HoldyTable tb = new HoldyTable { EmpID = UserClass.XEmpId, HoldyDate = holdyDateTimePicker.Value.Date, HoldType = HoldyTypeDropDownList.Text, }; HoldyCmd.addHoldy(tb); RadMessageBox.Show("تمت عملية الحفظ", "تمت", MessageBoxButtons.OK, RadMessageIcon.Info); Loginfrm myForm = (Loginfrm)Application.OpenForms["Loginfrm"]; myForm.Show(); this.Close(); }
public static bool addHoldy(HoldyTable tb) { db = new DbDataContext(); db.HoldyTables.InsertOnSubmit(tb); db.SubmitChanges(); return(true); }
public static bool EditHoldy(HoldyTable tb) { db = new DbDataContext(); var q = db.HoldyTables.Where(p => p.Id == tb.Id).SingleOrDefault(); q.EmpID = tb.EmpID; q.HoldType = tb.HoldType; q.HoldyDate = tb.HoldyDate; db.SubmitChanges(); return(true); }
public static HoldyTable CheckHoldy(int usr, DateTime date1) { db = new DbDataContext(); try { HoldyTable q = db.HoldyTables.Where(p => p.EmpID == usr && p.HoldyDate == date1).Single(); if (q.EmpID == usr && q.HoldyDate == date1) { return(q); } return(null); } catch (Exception) { return(null); } }
private void AddBtn_Click(object sender, EventArgs e) { #region " CheckFillTextBox " if (EmpComboBox.Text == "") { EmpComboBox.MultiColumnComboBoxElement.BackColor = Color.OrangeRed; EmpComboBox.Focus(); return; } else { EmpComboBox.MultiColumnComboBoxElement.BackColor = Color.White; } if (EmpComboBox.SelectedValue == null) { EmpComboBox.MultiColumnComboBoxElement.BackColor = Color.OrangeRed; EmpComboBox.Focus(); return; } else { EmpComboBox.MultiColumnComboBoxElement.BackColor = Color.White; } if (HoldyTypeDropDownList.Text == "") { HoldyTypeDropDownList.BackColor = Color.OrangeRed; HoldyTypeDropDownList.Focus(); return; } else { HoldyTypeDropDownList.BackColor = Color.White; } #endregion var q = HoldyCmd.CheckHoldy(int.Parse(EmpComboBox.SelectedValue.ToString()), holdyDateTimePicker.Value.Date); if (q != null) { RadMessageBox.Show("مسجل في هذا التاريخ مسبقاً", "خطأ", MessageBoxButtons.OK, RadMessageIcon.Error); return; } HoldyTable tb = new HoldyTable() { EmpID = int.Parse(EmpComboBox.SelectedValue.ToString()), HoldyDate = holdyDateTimePicker.Value.Date, HoldType = HoldyTypeDropDownList.Text, }; HoldyCmd.addHoldy(tb); RadMessageBox.Show("تمت عملية الحفظ", "تمت", MessageBoxButtons.OK, RadMessageIcon.Info); EmpComboBox.Focus(); HoldyTypeDropDownList.ResetText(); }