Example #1
0
 public void btnDelete_Click(System.Object sender, System.EventArgs e)
 {
     if (MessageBox.Show("سوف يتم حذف...هل هل انت متاكد؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
     {
         mTable.Delete("Code=N\'" + txtCode.Text.Trim() + "\'");
         btnNew_Click(null, null);
     }
 }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Properties.Settings.Default.Save();

            HRSetings.Delete();
            HRSetings.Add_New();

            HRSetings["MonthStart"] = txtMonthStart.Value.Date;
            HRSetings["MonthEnd"]   = txtMonthEnd.Value.Date;
            HRSetings.Update();
        }
Example #3
0
        public void btnDelete_Click(System.Object sender, System.EventArgs e)
        {
            bool Result =
                System.Convert.ToBoolean(MessageBox.Show("سوف يتم حذف...هل هل انت متاكد؟", "حذف",
                                                         MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation));

            if (Result)
            {
                mTable.Delete("Code=N\'" + txtCode.Text.Trim() + "\'");
                btnNew_Click(null, null);
                Tree1.FillTree();
            }
        }
Example #4
0
        public void btnSave_Click(System.Object sender, System.EventArgs e)
        {
            if (txtCode.Text.Trim() == "")
            {
                MessageBox.Show("من فضلك ادخل الكود", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (txtName.Text.Trim() == "")
            {
                MessageBox.Show("من فضلك ادخل الاسم", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (NewRecord && mTable.find("Code=N\'" + txtCode.Text.Trim() + "\'"))
            {
                MessageBox.Show("الكود موجود من قبل...ولا يمكن اضافة جديد بهذا الكود", "", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                txtCode.Text = "";
                return;
            }

            if (txtFingerPrintCode.Text.Trim() != "")
            {
                if (mTable.find("Code<>N\'" + txtCode.Text.Trim() + "\' and FingerPrintCode=" + txtFingerPrintCode.Text))
                {
                    MessageBox.Show(
                        string.Format("كود الموظف علي ماكنية البصمة موجود بالفعل علي الموظف : {0}", mTable["Code"]), "",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtFingerPrintCode.Text = "";
                    return;
                }
            }
            NewRecord = false;

            mTable.Add_New();

            mTable["Code"]            = (BasicDataNo ? Convert.ToInt64(txtCode.Text).ToString() : txtCode.Text);
            mTable["Name"]            = txtName.Text;
            mTable["FingerPrintCode"] = txtFingerPrintCode.Text;
            mTable["Gender"]          = cmbGender.SelectedIndex;
            mTable["ReligionCode"]    = cmbReligionCode.SelectedValue;
            mTable.SetFiled(txtDateofBirth);
            mTable["PlaceofBirth"] = txtPlaceofBirth.Text;
            mTable["MotherName"]   = txtMotherName.Text;
            mTable["FatherName"]   = txtFatherName.Text;

            mTable["HealthOfficecode"] = cmbHealthOfficecode.SelectedValue;
            mTable["NationalID"]       = txtNationalID.Text;
            mTable.SetFiled(txtNationalIDDate);
            mTable["InusranceID"]     = txtInusranceID.Text;
            mTable["MaterialState"]   = cmbMaterialState.SelectedIndex;
            mTable["MilitaryService"] = cmbMilitaryService.SelectedIndex;
            //--------------------

            if (Pic.Image != null)
            {
                Bitmap newBitmap1 = new Bitmap(Pic.Image);
                var    ms1        = new MemoryStream();
                newBitmap1.Save(ms1, ImageFormat.Jpeg);
                byte[] photoAray1 = new byte[ms1.Length];
                ms1.Position = 0;
                ms1.Read(photoAray1, 0, photoAray1.Length);
                ms1.Close();
                mTable["EmployeePicture"] = photoAray1;
            }

            //--------------------


            mTable["Tel1"]     = txtTel1.Text;
            mTable["Tel2"]     = txtTel2.Text;
            mTable["Mobile1"]  = txtMobile1.Text;
            mTable["Mobile2"]  = txtMobile2.Text;
            mTable["Email"]    = txtEmail.Text;
            mTable["CityCode"] = cmbCity.SelectedValue;
            //--------------------
            mTable["VariableSalary"] = txtVariableSalary.Text;
            mTable["BasicSalary"]    = txtBasicSalary.Text;
            mTable["JobCode"]        = cmbJobs.SelectedValue;
            mTable["DeptCode"]       = cmbDepts.SelectedValue;
            mTable["ManagementCode"] = cmbManagements.SelectedValue;
            mTable["Qualification"]  = cmbQualification.SelectedValue;
            mTable["WorkStatus"]     = cmbWorkStatus.SelectedIndex;
            mTable["Manager"]        = cmbManager.SelectedValue;
            mTable["Specialization"] = txtSpecialization.Text;
            mTable.SetFiled(dtbDateofLeavingWork);
            mTable.SetFiled(dtpDateofAppointment);
            mTable["HourPrice"] = txtHourPrice.Text;

            mTable.Update("Code=N\'" + txtCode.Text.Trim() + "\'");

            //------------shifts---------------
            var mEmployeesShifts = new MATRIX("EmployeesShifts");
            //mEmployeesShifts.Delete(string.Format("Employeecode='{0}'", txtCode.Text));
            //for (int i = 1; i < grdShifts.Rows.Count; i++)
            //{
            //    if (grdShifts[i, "ShiftName"] != null)
            //    {
            //        mEmployeesShifts.Add_New();
            //        mEmployeesShifts.SetFiled("EmployeeCode", txtCode.Text);
            //        mEmployeesShifts.SetFiled("ShiftCode", grdShifts[i, "ShiftName"]);
            //        mEmployeesShifts.Update();
            //    }
            //}
            //------------HoliDays---------------

            var mEmployeesHoliDays = new MATRIX("EmployeesHoliDays");
            //mEmployeesHoliDays.Delete(string.Format("Employeecode='{0}'", txtCode.Text));
            //for (int i = 1; i < grdHoliDays.Rows.Count; i++)
            //{
            //    if (grdHoliDays[i, "chk"] != null && (bool)grdHoliDays[i, "chk"])
            //    {
            //        mEmployeesHoliDays.Add_New();
            //        mEmployeesHoliDays.SetFiled("EmployeeCode", txtCode.Text);
            //        mEmployeesHoliDays.SetFiled("EnglishName", grdHoliDays[i, "EnglishName"]);
            //        mEmployeesHoliDays.Update();
            //    }
            //}

            //------------      الاستقطاعات      ---------------



            var mEmployees2 = new MATRIX("Employees2");


            mEmployees2.Delete(string.Format("Employeecode='{0}'", txtCode.Text));

            //for (int i = 1; i < grdDeduction.Rows.Count; i++)
            //{
            //    if ((grdDeduction[i, "DeductiontName"] + "").Trim() != "")
            //    {
            //        mEmployees2.Add_New();
            //        mEmployees2.SetFiled("EmployeeCode", txtCode.Text);
            //        mEmployees2.SetFiled("Code", grdDeduction[i, "DeductiontName"]);
            //        mEmployees2.SetFiled("DataType", 1);
            //        mEmployees2.SetFiled("Type", grdDeduction[i, "Type"]);
            //        mEmployees2.SetFiled("Qty", grdDeduction[i, "Qty"]);
            //        mEmployees2.SetFiled("Value", grdDeduction[i, "Value"]);
            //        mEmployees2.Update();
            //    }
            //}

            //------------      الاستحقاقات    ---------------
            mEmployees2 = new MATRIX("Employees2");

            //for (int i = 1; i < grdMerit.Rows.Count; i++)
            //{
            //    if ((grdMerit[i, "MerittName"] + "").Trim() != "")
            //    {
            //        mEmployees2.Add_New();
            //        mEmployees2.SetFiled("EmployeeCode", txtCode.Text);
            //        mEmployees2.SetFiled("Code", grdMerit[i, "MerittName"]);
            //        mEmployees2.SetFiled("DataType", 2);
            //        mEmployees2.SetFiled("Type", grdMerit[i, "Type"]);
            //        mEmployees2.SetFiled("Qty", grdMerit[i, "Qty"]);
            //        mEmployees2.SetFiled("Value", grdMerit[i, "Value"]);
            //        mEmployees2.Update();
            //    }
            //}

            //for (int i = 0; i < pnlPic.Controls.Count; i++)
            //{
            //    var doc =new EmployeesDocument();

            //    doc.DocPic= (PictureBox)[i]

            //}
            mEmployees2 = new MATRIX("EmployeesDocuments");
            mEmployees2.Delete(string.Format("Employeecode='{0}'", txtCode.Text));
            foreach (var pic_ in pnlPic.Controls)
            {
                var pic = new PictureBox();
                pic.Image = ((PictureBox)pic_).Image;
                mEmployees2.Add_New();
                mEmployees2["EmployeeCode"] = txtCode.Text;

                //---------------------
                //MemoryStream ms = new MemoryStream();
                //pic.Image.Save(ms, pic.Image.RawFormat);
                //byte[] a = ms.ToArray();

                Bitmap newBitmap = new Bitmap(pic.Image);
                var    ms        = new MemoryStream();
                newBitmap.Save(ms, ImageFormat.Jpeg);
                byte[] photoAray = new byte[ms.Length];
                ms.Position = 0;
                ms.Read(photoAray, 0, photoAray.Length);
                ms.Close();
                mEmployees2["DocPic"] = photoAray;
                //---------------------
                mEmployees2.Update();
            }


            //------------

            if (SaveMsgDontShow)
            {
                btnNew_Click(null, null);
            }
            else if (
                MessageBox.Show("تم حفظ البيانات...هل تريد مستند جديد؟", "حفظ", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Information) == DialogResult.Yes)
            {
                btnNew_Click(null, null);
            }
            else
            {
                Retrieve();
            }
            Tree1.FillTree();
        }
        public void btnSave_Click(System.Object sender, System.EventArgs e)
        {
            //-----------------------------------------------


            if (Settings.CurrentBox == "")
            {
                MessageBox.Show("لا يوجد كاشير علي المستخدم الحالي....من فضلك حاول مرة اخري", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            //if (!Pub.ShiftIsOpen(ShiftOrderNo))
            //{
            //    MessageBox.Show("تم قفل الوردية الحالية ولا يمكن الاستمرار من فضل اغلاق البرنامج ثم حاول مرة اخرى", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    return;
            //}


            exx :;
            Settings.ExecuteReader("select * from ShiftsOpening2 where OrderNo=" + ShiftOrderNo + " and Year=" + Settings.CurrentYear + "  and Branch_ID=N'" + Settings.CurrentBranch_ID + "' and BoxCode=N'" + Settings.CurrentBox + "'");
            if (Settings.DR.HasRows == false)
            {
                if (MessageBox.Show("سوف يتم فتح الكاشير الحالي علي الوردية الحالية", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    //FrmKasherOpen frm = new FrmKasherOpen();
                    //frm.ShowDialog();
                    goto exx;
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (Settings.DR["BoxStatus"].ToString() == "1")
                {
                    MessageBox.Show("تم قفل الكاشير ولا يمكن الاستمرار", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    return;
                }
            }
            //-----------------------------------------------

            if (txtName.Text.Trim() == "")
            {
                MessageBox.Show(" من فضلك ادخل الموظف", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            //s = " Year=" + Pub.CurrentYear + "  and Branch_ID=N'" + Pub.CurrentBranch
            //    + "' and ShiftOrderNo=" + ShiftOrderNo + "  and BoxCode=N'" + Pub.CurrentBox
            //    + "' and EmployeesCode=N'" + txtCode.Text.Trim() + "'";

            //Pub.ExecuteReader("select OrderNo from PaymentsEmployeesBetween where " + s);
            //if (Pub.DR.HasRows)
            //{
            //    MessageBox.Show(" هذا الموظف تم عليه حركة مدفوعات علي هذه الوردية", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    return;
            //}



            //if (NewRecord == false && Pub.PaymentsEditDelete == false)
            //{

            //    MessageBox.Show("هذا المستخدم لايستطيع التعديل ", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    if (Pub.ManagerPassword("PaymentsEditDelete") == false)
            //    {
            //        MessageBox.Show("هذا المستخدم لايستطيع التعديل من فضلك حاول مرة اخرى", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //        return;
            //    }
            //}

            if (txtTotal.Text == "")
            {
                MessageBox.Show("لا يوجد مبالغ....لايمكن الحفظ", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            try
            {
                mTable.ExecuteNonQuery("BEGIN TransACTION " + Name);

                if (NewRecord)
                {
                    s = " Year=" + Settings.CurrentYear + "  and Branch_ID=N'" + Settings.CurrentBranch_ID + "' and ShiftOrderNo=" + ShiftOrderNo + "  and BoxCode=N'" + Settings.CurrentBox + "'  and OrderNo=" + txtOrderNo.Text;
                    Settings.ExecuteReader("select OrderNo from PaymentsEmployeesBetween where " + s);

                    if (Settings.DR.HasRows)
                    {
                        s = " Year=" + Settings.CurrentYear + "  and Branch_ID=N'" + Settings.CurrentBranch_ID + "' and ShiftOrderNo=" + ShiftOrderNo + "  and BoxCode=N'" + Settings.CurrentBox + "'";
                        txtOrderNo.Text = mTable.Get_New("orderNo", s);
                    }
                }
                mTable.Add_New();
                mTable.SetFiled("Year", Settings.CurrentYear);
                mTable.SetFiled("Branch_ID", Settings.CurrentBranch_ID);
                mTable.SetFiled("BoxCode", Settings.CurrentBox);
                mTable.SetFiled("OrderNo", txtOrderNo.Text);
                mTable.SetFiled(dtpOrderDate);
                mTable.SetFiled("ShiftOrderNo", ShiftOrderNo);
                mTable.SetFiled("EmployeesCode", txtCode.Text);
                mTable.SetFiled("Total", txtTotal.Text);
                mTable.SetFiled("Posted", 1);

                s = " Year=" + Settings.CurrentYear + "  and Branch_ID=N'" + Settings.CurrentBranch_ID + "' and ShiftOrderNo=" + ShiftOrderNo + "   and BoxCode=N'" + Settings.CurrentBox + "' and OrderNo=" + txtOrderNo.Text;
                mTable.Update(s);



                //------------------------------------
                s = " Year=" + Settings.CurrentYear + "  and Branch_ID=N'" + Settings.CurrentBranch_ID + "' and ShiftOrderNo=" + ShiftOrderNo + "   and BoxCode=N'" + Settings.CurrentBox + "' and OrderNo=" + txtOrderNo.Text;
                mTable2.Delete(s);

                for (int i = 0; i < grd.Rows.Count; i++)
                {
                    mTable2.Add_New();
                    mTable2.SetFiled("Year", Settings.CurrentYear);
                    mTable2.SetFiled("Branch_ID", Settings.CurrentBranch_ID);
                    mTable2.SetFiled("BoxCode", Settings.CurrentBox);
                    mTable2.SetFiled("OrderNo", txtOrderNo.Text);
                    mTable2.SetFiled("ShiftOrderNo", ShiftOrderNo);
                    mTable2.SetFiled("Ser", i);

                    mTable2.SetFiled("ShiftOrderNo2", grd.Rows[i].Cells["OrderNo"].Value.ToString());

                    mTable2.SetFiled("OrderDate2", Convert.ToDateTime(grd.Rows[i].Cells["OrderDate"].Value));


                    if (grd.Rows[i].Cells["TimeIn"].Value.ToString() != "")
                    {
                        mTable2.SetFiled("AttIn", Convert.ToDateTime(grd.Rows[i].Cells["TimeIn"].Value));
                    }
                    else
                    {
                        mTable2.SetFiled("AttIn", DBNull.Value);
                    }

                    if (grd.Rows[i].Cells["TIMEOUT"].Value.ToString() != "")
                    {
                        mTable2.SetFiled("AttOUT", Convert.ToDateTime(grd.Rows[i].Cells["TIMEOUT"].Value));
                    }
                    else
                    {
                        mTable2.SetFiled("AttOUT", DBNull.Value);
                    }

                    mTable2.SetFiled("ActulMinute", grd.Rows[i].Cells["ActulMinute"].Value);
                    mTable2.SetFiled("Salary", grd.Rows[i].Cells["Salary"].Value);
                    mTable2.Update();
                }

                mTable.ExecuteNonQuery("COMMIT TransACTION " + Name);


                NewRecord = false;

                if (SaveMsgDontShow)
                {
                    btnNew_Click(null, null);
                }
                else
                if (MessageBox.Show("تم حفظ البيانات...هل تريد مستند جديد؟", "حفظ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    btnNew_Click(null, null);
                }
                else
                {
                    Retrieve();
                }
            }
            catch (Exception Ex)
            {
                //mTable.ExecuteNonQuery("Rollback TransACTION " + Name);
                MessageBox.Show(Ex.Message);
                return;
            }
        }