Esempio n. 1
0
 private void menuItem2_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Filter = "位图(*.bmp)|*.bmp|JPEG(*.jpg)|*.jpg;*.jpeg;*,jpe|Gif(*.gif)|*.gif|Png(*.png)|*.png|所有文件(*.*)|*.*";
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         try
         {
             Bitmap bm = tendencyChart1.CreateBitmap();
             if (saveFileDialog1.FilterIndex == 1)
             {
                 bm.Save(saveFileDialog1.FileName, ImageFormat.Bmp);
             }
             if (saveFileDialog1.FilterIndex == 2)
             {
                 bm.Save(saveFileDialog1.FileName, ImageFormat.Jpeg);
             }
             if (saveFileDialog1.FilterIndex == 3)
             {
                 bm.Save(saveFileDialog1.FileName, ImageFormat.Gif);
             }
             if (saveFileDialog1.FilterIndex == 5)
             {
                 bm.Save(saveFileDialog1.FileName, ImageFormat.Png);
             }
         }
         catch (Exception MyEx)
         {
             MessageBox.Show(MyEx.ToString(), "错误提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
         }
     }
 }
Esempio n. 2
0
        public IList <string> GetCurrent()
        {
            IList <string> Res = new List <string>();

            string sSQL = "SELECT `00current`.fecha, `00equipos`.nombre, `00current`.temperatura, `00current`.humedad, `00current`.co, `00current`.consumo" + "\n" +
                          "FROM `00current` INNER JOIN `00equipos` ON `00current`.equipo = `00equipos`.ip";

            MySql.Data.MySqlClient.MySqlCommand MyComm =
                new MySql.Data.MySqlClient.MySqlCommand(sSQL, MySQLConn);

            try
            {
                MySql.Data.MySqlClient.MySqlDataReader MyReader = MyComm.ExecuteReader();
                if (MyReader.HasRows)
                {
                    while (MyReader.Read())
                    {
                        Res.Add(new Lectura(MyReader.GetDateTime("fecha"),
                                            MyReader.GetString("nombre"),
                                            MyReader.GetDouble("temperatura"),
                                            MyReader.GetDouble("humedad"),
                                            MyReader.GetDouble("co"),
                                            MyReader.GetDouble("consumo")).ToString());
                    }
                }
                MyReader.Close();
            }
            catch (MySql.Data.MySqlClient.MySqlException MyEx)
            {
                ErrLogger.LogError(MyEx.ToString(), System.Diagnostics.EventLogEntryType.Error);
                Res = new List <string>();
            }

            return(Res);
        }
Esempio n. 3
0
        private void picEmergeSave_Click(object sender, EventArgs e)
        {
            foreach (DataRow drStaff in dsBelfray.Tables["Staff"].Rows)
            {
                if (drStaff["staffID"].ToString().Equals(lblStaffNo.Text))
                {
                    MyStaff myStaff = new MyStaff();
                    bool    ok      = true;
                    errP.Clear();

                    //Contact Name
                    try
                    {
                        myStaff.ContactName = txtContactName.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtContactName, MyEx.toString());
                    }

                    //Contact Tel No
                    try
                    {
                        myStaff.ContactTelNo = txtContactTel.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtPhoneNo, MyEx.toString());
                    }

                    //Try Adding
                    try
                    {
                        if (ok)
                        {
                            drStaff.BeginEdit();
                            drStaff["staffEmergName"] = myStaff.ContactName;
                            drStaff["staffEmergTel"]  = myStaff.ContactTelNo;
                            drStaff.EndEdit();
                            daStaff.Update(dsBelfray, "Staff");

                            MessageBox.Show("Emergency Contact Info Updated");

                            picEmergeCancel.Visible = false;
                            picEmergeSave.Visible   = false;
                            picEmergeEdit.Visible   = true;

                            txtContactName.Enabled = false;
                            txtContactTel.Enabled  = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                    }
                }
            }
        }
Esempio n. 4
0
        public IList <DescripcionEquipo> GetEquipos()
        {
            IList <DescripcionEquipo> Res = new List <DescripcionEquipo>();

            string InsertSQL = string.Format("SELECT id, ip, nombre FROM `00equipos`");

            MySql.Data.MySqlClient.MySqlCommand MySQLComm =
                new MySql.Data.MySqlClient.MySqlCommand(InsertSQL, MySQLConn);

            try
            {
                MySql.Data.MySqlClient.MySqlDataReader MyReader = MySQLComm.ExecuteReader();
                if (MyReader.HasRows)
                {
                    while (MyReader.Read())
                    {
                        Res.Add(
                            new DescripcionEquipo(
                                MyReader.GetString("id"),
                                MyReader.GetString("ip"),
                                MyReader.IsDBNull(2) ? "Sin Nombre" : MyReader.GetString("nombre")));
                    }
                }
                MyReader.Close();
            }
            catch (MySql.Data.MySqlClient.MySqlException MyEx)
            {
                ErrLogger.LogError(MyEx.ToString(), System.Diagnostics.EventLogEntryType.Error);
                Res = new List <DescripcionEquipo>();
            }

            return(Res);
        }
Esempio n. 5
0
        private void picSaveADDPTD_Click(object sender, EventArgs e)
        {
            MyProdTypeCode myProdType = new MyProdTypeCode();
            bool           ok         = true;

            errP.Clear();

            try
            {
                myProdType.ProdTypeCode = txtProdTypeCode.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtProdTypeCode, MyEx.toString());
            }
            try
            {
                myProdType.ProdTypeDesc = txtProdDesc2.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtProdDesc2, MyEx.toString());
            }
            //Try Adding
            try
            {
                if (ok)
                {
                    drProductType = dsBelfray.Tables["ProductType"].NewRow();
                    drProductType["productTypeCode"] = myProdType.ProdTypeCode;
                    drProductType["productTypeDesc"] = myProdType.ProdTypeDesc;
                    dsBelfray.Tables["ProductType"].Rows.Add(drProductType);
                    daProductType.Update(dsBelfray, "ProductType");

                    MessageBox.Show("Product Type Added");
                    if (MessageBox.Show("Do you wish to add another product type?", "AddProductType", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        txtProdTypeCode.Text = "";
                        txtProdDesc2.Text    = "";
                        formLoad             = true;
                        test = true;
                    }
                    else
                    {
                        pnlProdType.Enabled  = false;
                        txtProdTypeCode.Text = "";
                        txtProdDesc2.Text    = "";
                        pnlDetails.Enabled   = true;
                        formLoad             = true;
                        test = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        public IList <string> GetLecturas(string IdEquipo, Periodicidad Periodicidad, DateTime FechaInicio, DateTime FechaFin)
        {
            //Obtiene la lista de las lecturas
            IList <string> Res = new List <string>();

            string TablaPeriodicidad = "";

            switch (Periodicidad)
            {
            case Periodicidad.TiempoReal:
                TablaPeriodicidad = "`01input`";
                break;

            case Periodicidad.Diario:
                TablaPeriodicidad = "`02diario`";
                break;

            case Periodicidad.Mensual:
            default:
                TablaPeriodicidad = "`03mensual`";
                break;
            }

            string sSQL = "SELECT T2.ip, T1.fecha, T1.temperatura, T1.humedad, T1.co, T1.consumo" + "\n" +
                          "FROM " + TablaPeriodicidad + " T1" + " INNER JOIN" + "\n" +
                          "`00equipos` T2 ON T1.equipo = T2.ip" + "\n" +
                          "WHERE (fecha BETWEEN '" + FechaInicio.ToString("yyyy-MM-dd HH:mm:ss") + "' AND '" + FechaFin.ToString("yyyy-MM-dd HH:mm:ss") + "') AND (T2.id = '" + IdEquipo + "')";

            MySql.Data.MySqlClient.MySqlCommand MyComm =
                new MySql.Data.MySqlClient.MySqlCommand(sSQL, MySQLConn);

            try
            {
                MySql.Data.MySqlClient.MySqlDataReader MyReader = MyComm.ExecuteReader();
                if (MyReader.HasRows)
                {
                    while (MyReader.Read())
                    {
                        Res.Add(new Lectura(MyReader.GetDateTime("fecha"),
                                            MyReader.GetString("ip"),
                                            MyReader.GetDouble("temperatura"),
                                            MyReader.GetDouble("humedad"),
                                            MyReader.GetDouble("co"),
                                            MyReader.GetDouble("consumo")).ToString());
                    }
                }
                MyReader.Close();
            }
            catch (MySql.Data.MySqlClient.MySqlException MyEx)
            {
                ErrLogger.LogError(MyEx.ToString(), System.Diagnostics.EventLogEntryType.Error);
                Res = new List <string>();
            }

            return(Res);
        }
        //THIS DOESNT WORK
        private void PicSaveADDPTD_Click(object sender, EventArgs e)
        {
            //ProductTypeCode
            drProductType = dsBelfray.Tables["ProductType"].Rows.Find(lblPTC.Text);

            MyProdTypeCode myProdType = new MyProdTypeCode();
            bool           ok         = true;

            errP.Clear();

            try
            {
                myProdType.ProdTypeCode = lblPTC.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblPTC, MyEx.toString());
            }
            try
            {
                myProdType.ProdTypeDesc = txtProdDesc2.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtProdDesc2, MyEx.toString());
            }
            //Try
            try
            {
                if (ok)
                {
                    drProductType.BeginEdit();
                    drProductType["productTypeDesc"] = myProdType.ProdTypeDesc;
                    drProductType.EndEdit();
                    daProductType.Update(dsBelfray, "ProductType");
                    pnlProdType.Enabled  = false;
                    lblPTC.Enabled       = false;
                    txtProdDesc2.Enabled = false;
                    chkBxEditPTD.Checked = false;
                    this.Update();

                    MessageBox.Show("Product Type Edited");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 8
0
	public static int test (int a) {
		int res;
		int fin = 0;
		try {
			res = 10/a;
			throw new MyEx ();
		} catch (Exception ex) {
			ex = new MyEx ();
			throw;
		} finally {
			fin = 1;
		}
		return res;
	}
Esempio n. 9
0
    public static int test(int a)
    {
        int res;
        int fin = 0;

        try {
            res = 10 / a;
            throw new MyEx();
        } catch (Exception ex) {
            ex = new MyEx();
            throw;
        } finally {
            fin = 1;
        }
        return(res);
    }
        static public void Main()
        {
            Tank T1 = new Tank(1);
            Tank T2 = new Tank(1);
            Tank T3 = new Tank(1);
            Tank T4 = new Tank(1);
            Tank T5 = new Tank(1);
            Tank P1 = new Tank(2);
            Tank P2 = new Tank(2);
            Tank P3 = new Tank(2);
            Tank P4 = new Tank(2);
            Tank P5 = new Tank(2);

            Tank[] arrT = new Tank[] { T1, T2, T3, T4, T5 };
            Tank[] arrP = new Tank[] { P1, P2, T1, P4, P5 };
            bool   win;

            for (int i = 0; i < 5; i++)
            {
                arrT[i].Show();
                arrP[i].Show();
                try{
                    MyEx e = new MyEx();
                    if (arrT[i].GetName().ToCharArray()[0] == arrP[i].GetName().ToCharArray()[0])
                    {
                        throw e;
                    }
                    win = arrT[i] * arrP[i];
                }
                catch (MyEx e) {
                    WriteLine(e.Message);
                }
                WriteLine("--------------------------------------");
            }

            /*T1.Show();
             * T2.Show();
             * T3.Show();
             * P1.Show();
             * P2.Show();
             * bool vin = T1*P1;
             */
        }
Esempio n. 11
0
    public static int test(int a)
    {
        int res;
        int fin = 0;

        try {
            res = 10 / a;
            throw new MyEx();
        } catch (Exception ex) {
            //
            // Beginn Aenderung Test
            //
            Console.WriteLine(ex.ToString());
            //
            // Ende Aenderung Test
            //
            ex = new MyEx();
            throw;
        } finally {
            fin = 1;
        }
        return(res);
    }
Esempio n. 12
0
        private void btnConfirmPay_Click(object sender, EventArgs e)
        {
            bool ok = true;

            errP.Clear();
            foreach (DataRow dr in dtPayToday.Rows)
            {
                MyTrans myTrans = new MyTrans();

                errP.Clear();

                drTrans = dsKaizen.Tables["Trans"].Rows.Find(dr[0].ToString());

                try
                {
                    myTrans.CustID = txtCustID.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtCustID, MyEx.toString());
                }

                try
                {
                    myTrans.TransOn = DateTime.Parse(dr[2].ToString());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    myTrans.TransTotal = Convert.ToDouble(drTrans["TransTotal"].ToString());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }
                try
                {
                    myTrans.BalOwed = 0.00;
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    if (ok)
                    {
                        drTrans.BeginEdit();
                        drTrans["CustID"]      = myTrans.CustID;
                        drTrans["TransDate"]   = myTrans.TransOn;
                        drTrans["TransTotal"]  = myTrans.TransTotal;
                        drTrans["BalanceOwed"] = myTrans.BalOwed;

                        if (myTrans.BalOwed <= 0)
                        {
                            drTrans["Paid"] = 'Y';
                        }
                        else
                        {
                            drTrans["Paid"] = 'N';
                        }

                        drTrans.EndEdit();
                        daTrans.Update(dsKaizen, "Trans");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                    MessageBoxIcon.Error);
                }

                MyPayment myPayment = new MyPayment();

                getPaysnum();

                try
                {
                    myPayment.PayID = "PY-" + (seperateNumber(findPayID) + 1).ToString();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    myPayment.TransID = dr[0].ToString();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    myPayment.PayAmount = Convert.ToDouble(dr[1].ToString());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    myPayment.PayDate = DateTime.Today;
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }


                if (ok)
                {
                    drPayment              = dsKaizen.Tables["Payments"].NewRow();
                    drPayment["PayID"]     = myPayment.PayID;
                    drPayment["TransID"]   = myPayment.TransID;
                    drPayment["PayAmount"] = myPayment.PayAmount;
                    drPayment["PayDate"]   = myPayment.PayDate;



                    dsKaizen.Tables["Payments"].Rows.Add(drPayment);
                    daPayments.Update(dsKaizen, "Payments");
                }
                MessageBox.Show("Payment Taken", "Order");
                populateCustOutStandingTrans(txtCustID, dgvLoadTrans);
            }
        }
        private void picCustomerSave_Click(object sender, EventArgs e)
        {
            MyCustomer myCust = new MyCustomer();
            bool       ok     = true;

            errP.Clear();

            //Customer Number
            try
            {
                myCust.CustomerNumber = lblCustNo.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblCustNo, MyEx.toString());
            }

            //Customer Title
            try
            {
                myCust.Title = cmbTitle.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmbTitle, MyEx.toString());
            }

            //Customer Forename
            try
            {
                myCust.Forename = txtForename.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtForename, MyEx.toString());
            }

            //Customer Surname
            try
            {
                myCust.Surname = txtSurname.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSurname, MyEx.toString());
            }

            //Customer Street
            try
            {
                myCust.Street = txtStreet.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtStreet, MyEx.toString());
            }

            //Customer City
            try
            {
                myCust.City = txtCity.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtCity, MyEx.toString());
            }

            //Customer County
            try
            {
                myCust.County = txtCounty.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtCounty, MyEx.toString());
            }

            //Customer PostCode
            try
            {
                myCust.Postcode = txtPostcode.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPostcode, MyEx.toString());
            }

            //Customer TelNo
            try
            {
                myCust.TelNo = txtPhoneNo.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPhoneNo, MyEx.toString());
            }

            //Try Adding
            try
            {
                if (ok)
                {
                    drCustomer = dsBelfray.Tables["Customer"].NewRow();
                    drCustomer["customerNo"]       = myCust.CustomerNumber;
                    drCustomer["customerTitle"]    = myCust.Title;
                    drCustomer["customerForename"] = myCust.Forename;
                    drCustomer["customerSurname"]  = myCust.Surname;
                    drCustomer["customerStreet"]   = myCust.Street;
                    drCustomer["customerCity"]     = myCust.City;
                    drCustomer["customerCounty"]   = myCust.County;
                    drCustomer["customerPostcode"] = myCust.Postcode;
                    drCustomer["customerTel"]      = myCust.TelNo;
                    dsBelfray.Tables["Customer"].Rows.Add(drCustomer);
                    daCustomer.Update(dsBelfray, "Customer");

                    MessageBox.Show("Customer Added");

                    clearCustomerPanel();

                    custPanelCont();
                    bookPanelCont();

                    int noRows = dsBelfray.Tables["Customer"].Rows.Count;

                    //cb ProductType
                    cmbCustomerNo.DataSource    = dsBelfray.Tables["Customer"];
                    cmbCustomerNo.ValueMember   = "customerNo";
                    cmbCustomerNo.DisplayMember = "customerNo";
                    cmbCustomerNo.SelectedIndex = noRows - 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 14
0
        private void btnPPay_Click(object sender, EventArgs e)
        {
            MyPayment myPayment = new MyPayment();
            bool      ok        = true;

            errP.Clear();

            try
            {
                myPayment.PayID = lblPPayInvID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblPPayInvID, MyEx.toString());
            }

            try
            {
                myPayment.TransID = txtPPayTransID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPPayTransID, MyEx.toString());
            }

            try
            {
                myPayment.PayAmount = Convert.ToDouble(txtBPayTo.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtBPayTo, MyEx.toString());
            }
            catch (FormatException Formex)
            {
                ok = false;
                errP.SetError(txtBPayTo, "Please Enter a vaild number");
            }


            if (ok)
            {
                drPayment              = dsKaizen.Tables["Payments"].NewRow();
                drPayment["PayID"]     = myPayment.PayID;
                drPayment["TransID"]   = myPayment.TransID;
                drPayment["PayAmount"] = myPayment.PayAmount;
                drPayment["PayDate"]   = myPayment.PayDate;



                dsKaizen.Tables["Payments"].Rows.Add(drPayment);
                daPayments.Update(dsKaizen, "Payments");



                MyTrans myTrans = new MyTrans();

                errP.Clear();

                drTrans = dsKaizen.Tables["Trans"].Rows.Find(txtPPayTransID.Text);

                try
                {
                    myTrans.CustID = lblPPayCustNo.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtCustID, MyEx.toString());
                }

                try
                {
                    myTrans.TransOn = dtpPPay.Value;
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(dtpPPay, MyEx.toString());
                }

                try
                {
                    myTrans.TransTotal = Convert.ToDouble(lblPPayTot.Text.Trim());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(lblPPayTot, MyEx.toString());
                }
                try
                {
                    myTrans.BalOwed = (Convert.ToDouble(lblPPayOut.Text.Trim())) - (Convert.ToDouble(txtBPayTo.Text.Trim()));
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtBPayTo, MyEx.toString());
                }

                try
                {
                    if (ok)
                    {
                        drTrans.BeginEdit();
                        drTrans["CustID"]      = myTrans.CustID;
                        drTrans["TransDate"]   = myTrans.TransOn;
                        drTrans["TransTotal"]  = myTrans.TransTotal;
                        drTrans["BalanceOwed"] = myTrans.BalOwed;

                        if (myTrans.BalOwed <= 0)
                        {
                            drTrans["Paid"] = 'Y';
                        }
                        else
                        {
                            drTrans["Paid"] = 'N';
                        }

                        drTrans.EndEdit();
                        daTrans.Update(dsKaizen, "Trans");

                        MessageBox.Show("Payment Taken", "Order");
                        clearMultiPayfrm();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                    MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 15
0
        private void btn_Multibook_Click(object sender, EventArgs e)
        {
            if (lbl_ClientNoTextBook.Text != "")
            {
                drclient = dsNWRC_HairBeauty.Tables["Client"].Rows.Find(lbl_ClientNoTextBook.Text);

                if (btn_Multibook.Text == "Edit Client")
                {
                    //enable Form Entries
                    formEnable(true);
                    btn_CancelBook.Visible = true;
                    btn_Multibook.Text     = "Save Client";
                }
                else
                {
                    MyClient myClient = new MyClient();
                    bool     ok       = true;
                    errP.Clear();

                    try
                    { myClient.ClientNo = Convert.ToInt32(lbl_ClientNoTextBook.Text.Trim()); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(lbl_ClientNoTextBook, MyEx.ToString());
                    }

                    try
                    { myClient.Title = cmb_TitleBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(cmb_TitleBook, MyEx.tostring());
                    }

                    try
                    { myClient.Surname = txt_SurnameBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_SurnameBook, MyEx.tostring());
                    }

                    try
                    { myClient.Forename = txt_ForenameBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_ForenameBook, MyEx.tostring());
                    }

                    try
                    { myClient.Street = rt_StreetBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(rt_StreetBook, MyEx.tostring());
                    }

                    try
                    { myClient.Town = txt_TownBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_TownBook, MyEx.tostring());
                    }

                    try
                    { myClient.County = txt_CountyBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_CountyBook, MyEx.tostring());
                    }

                    try
                    { myClient.Postcode = txt_PostcodeBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_PostcodeBook, MyEx.tostring());
                    }

                    try
                    { myClient.Country = txt_CountryBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_CountryBook, MyEx.tostring());
                    }

                    try
                    { myClient.TelNo = txt_TelephoneBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_TelephoneBook, MyEx.tostring());
                    }

                    try
                    { myClient.Email = txt_EmailBook.Text.Trim(); }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txt_EmailBook, MyEx.tostring());
                    }

                    try
                    {
                        if (chk_SkinBook.Checked)
                        {
                            myClient.SkinTest = "Yes";
                        }
                        else
                        {
                            myClient.SkinTest = "No";
                        }
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(chk_SkinBook, MyEx.tostring());
                    }
                    if (newClient)
                    {
                        drclient             = dsNWRC_HairBeauty.Tables["Client"].NewRow();
                        drclient["ClientNo"] = myClient.ClientNo;
                        drclient["Title"]    = myClient.Title;
                        drclient["Surname"]  = myClient.Surname;
                        drclient["Forename"] = myClient.Forename;
                        drclient["Street"]   = myClient.Street;
                        drclient["Town"]     = myClient.Town;
                        drclient["County"]   = myClient.County;
                        drclient["PostCode"] = myClient.Postcode;
                        drclient["Country"]  = myClient.Country;
                        drclient["TelNo"]    = myClient.TelNo;
                        drclient["Email"]    = myClient.Email;
                        drclient["SkinTest"] = myClient.SkinTest;

                        dsNWRC_HairBeauty.Tables["Client"].Rows.Add(drclient);
                        daClient.Update(dsNWRC_HairBeauty, "Client");

                        MessageBox.Show("New Customer " + lbl_ClientNoTextBook.Text + " added !!!");
                    }
                    else
                    {
                        try
                        {
                            if (ok)
                            {
                                drclient.BeginEdit();
                                drclient["Title"]    = myClient.Title;
                                drclient["Surname"]  = myClient.Surname;
                                drclient["Forename"] = myClient.Forename;
                                drclient["Street"]   = myClient.Street;
                                drclient["Town"]     = myClient.Town;
                                drclient["County"]   = myClient.County;
                                drclient["PostCode"] = myClient.Postcode;
                                drclient["Country"]  = myClient.Country;
                                drclient["TelNo"]    = myClient.TelNo;
                                drclient["Email"]    = myClient.Email;
                                drclient["SkinTest"] = myClient.SkinTest;

                                drclient.EndEdit();
                                daClient.Update(dsNWRC_HairBeauty, "Client");

                                MessageBox.Show("Customer " + lbl_ClientNoTextBook.Text + " Details have been Updated !!!");
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                        }
                    }
                    //Disable Form entries
                    formEnable(false);
                    btn_CancelBook.Visible = false;
                    btn_Multibook.Text     = "Edit Client";
                }
            }
        }
        private void picBookingSave_Click(object sender, EventArgs e)
        {
            MyBooking myBook = new MyBooking();

            MainWindow.maxCap = 0;
            bool ok = true;

            errP.Clear();

            //Booking Number
            try
            {
                myBook.BookingNumber = lblBookingNo.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblBookingNo, MyEx.toString());
            }

            //Check In Date
            try
            {
                myBook.CheckInDate = dtpBookingCheckIn.Value;
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(dtpBookingCheckIn, MyEx.toString());
            }

            //Check Out Date
            try
            {
                myBook.CheckOutDate = dtpBookingCheckOut.Value;
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(dtpBookingCheckOut, MyEx.toString());
            }

            //Check In Time
            try
            {
                myBook.BookingTime = "13:00";
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblCheckInTime, MyEx.toString());
            }

            //Customer Number
            try
            {
                myBook.CustomerNumber = cmbCustomerNo.SelectedValue.ToString();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmbCustomerNo, MyEx.toString());
            }

            //Payment Type
            try
            {
                myBook.PaymentTypeID = cmbPayType.SelectedValue.ToString();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmbPayType, MyEx.toString());
            }

            //Party Size
            try
            {
                for (int x = 0; x < 19; x++)
                {
                    MainWindow.maxCap += Globals.capacity[x];
                }

                if (int.Parse(txtPartySize.Text.Trim()) <= MainWindow.maxCap && int.Parse(txtPartySize.Text.Trim()) > 0)
                {
                    myBook.PartySize = int.Parse(txtPartySize.Text.Trim());
                }
                else
                {
                    ok = false;
                    errP.SetError(txtPartySize, "Party size must not exceed the capacity of the room, please enter a value of " + (MainWindow.maxCap) + " or less. Alternatively cancel and select a larger room.");
                }
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPartySize, MyEx.toString());
            }

            //Try Adding
            try
            {
                if (ok)
                {
                    drBooking = dsBelfray.Tables["Booking"].NewRow();
                    drBooking["bookingNo"]     = myBook.BookingNumber;
                    drBooking["checkInDate"]   = myBook.CheckInDate;
                    drBooking["checkOutDate"]  = myBook.CheckOutDate;
                    drBooking["bookingTime"]   = myBook.BookingTime;
                    drBooking["paymentTypeID"] = myBook.PaymentTypeID;
                    drBooking["partySize"]     = myBook.PartySize;
                    drBooking["customerNo"]    = myBook.CustomerNumber;
                    dsBelfray.Tables["Booking"].Rows.Add(drBooking);
                    daBooking.Update(dsBelfray, "Booking");

                    int roomRows = dgvRooms.RowCount;

                    for (int x = 0; x < roomRows; x++)
                    {
                        drBookingItem = dsBelfray.Tables["BookingItem"].NewRow();
                        drBookingItem["bookingNo"] = dgvRooms.Rows[x].Cells[0].Value.ToString();
                        drBookingItem["itemNo"]    = "RM" + dgvRooms.Rows[x].Cells[1].Value.ToString();
                        drBookingItem["itemQty"]   = DBNull.Value;
                        dsBelfray.Tables["BookingItem"].Rows.Add(drBookingItem);
                    }

                    daBookingItem.Update(dsBelfray, "BookingItem");

                    MessageBox.Show("Booking Added");

                    cancelled = true;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 17
0
        private void btnEditEdit_Click(object sender, EventArgs e)
        {
            if (btnEditStock.Text == "EDIT STOCK")
            {
                enableEditTxtboxes();

                btnEditStock.Text = "Save";
            }
            else
            {
                MyStock myStock = new MyStock();
                bool    ok      = true;
                errP.Clear();


                try
                {
                    myStock.StockDesc = txtEditDesc.Text.Trim();
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEditDesc, MyEx.toString());
                }

                try
                {
                    myStock.QtyInStock = Convert.ToInt32(txtEditQTY.Text.Trim());
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEditQTY, MyEx.toString());
                }
                catch (FormatException Formex)
                {
                    ok = false;
                    errP.SetError(txtEditQTY, "Please Enter a vaild number");
                }


                try
                {
                    myStock.EquipType = this.cmbEditProdType.GetItemText(this.cmbEditProdType.SelectedItem);
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(cmbEditProdType, MyEx.toString());
                }

                try
                {
                    myStock.PurPrice = Convert.ToDouble(txtEditPurchase.Text.Trim());
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEditPurchase, MyEx.toString());
                }
                catch (FormatException Formex)
                {
                    ok = false;
                    errP.SetError(txtEditPurchase, "Please Enter a vaild number");
                }

                try
                {
                    myStock.RentalPrice = Convert.ToDouble(txtEditRental.Text.Trim());
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEditRental, MyEx.toString());
                }
                catch (FormatException Formex)
                {
                    ok = false;
                    errP.SetError(txtEditRental, "Please Enter a vaild number");
                }

                try
                {
                    myStock.ServicePrice = Convert.ToDouble(txtEditService.Text.Trim());
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEditService, MyEx.toString());
                }
                catch (FormatException Formex)
                {
                    ok = false;
                    errP.SetError(txtEditService, "Please Enter a vaild number");
                }


                try
                {
                    myStock.SuppID = txtEditProdSupplierID.Text.Trim();
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEditProdSupplierID, MyEx.toString());
                }

                try
                {
                    if (ok)
                    {
                        drStock.BeginEdit();
                        drStock["StockDescription"] = myStock.StockDesc;
                        drStock["EquipType"]        = myStock.EquipType;
                        drStock["PurPrice"]         = myStock.PurPrice;
                        drStock["RentPrice"]        = myStock.RentalPrice;
                        drStock["ServPrice"]        = myStock.ServicePrice;
                        drStock["QtyInStock"]       = myStock.QtyInStock;
                        drStock["SuppID"]           = myStock.SuppID;

                        drStock.EndEdit();
                        daStock.Update(dsKaizen, "Stock");

                        MessageBox.Show("Stock Details Updated", "Stock");

                        disableEditTxtboxes();

                        btnEditStock.Text      = "EDIT STOCK";
                        tabStock.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                    MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 18
0
        private void btnEditTrans_Click(object sender, EventArgs e)
        {
            daTransD.Update(dsKaizen, "TransDetails");

            if (btnEditTrans.Text == "EDIT ORDER")
            {
                enableEdittxtB();

                btnEditTrans.Text = "SAVE";
            }
            else
            {
                gatherTransDForEdit(txtEditOrderID.Text);
                bool ok = true;

                for (int i = 0; i < ogTransDrows; i++)
                {
                    if (string.Equals(dt.Rows[i][1].ToString(), "Deleted"))
                    {
                        string deleteID = EditTransDTable.Rows[i][0].ToString();

                        deleteTranDets(deleteID);

                        daTransD.Update(dsKaizen, "TransDetails");
                    }
                    if (!Equals(dt.Rows[i][3], EditTransDTable.Rows[i][3]) || !Equals(dt.Rows[i][0], EditTransDTable.Rows[i][2]))
                    {
                        drTransDets = dsKaizen.Tables["TransDetails"].Rows.Find(EditTransDTable.Rows[i][0].ToString());

                        MyTransDetails myTransDetails = new MyTransDetails();

                        errP.Clear();

                        try
                        {
                            myTransDetails.StockID = drTransDets["StockID"].ToString();
                        }
                        catch (MyException MyEx)
                        {
                            ok = false;
                        }

                        try
                        {
                            myTransDetails.Qty = Convert.ToInt32(drTransDets["Qty"]);
                        }
                        catch (MyException MyEx)
                        {
                            ok = false;
                        }

                        try
                        {
                            if (ok)
                            {
                                drTransDets.BeginEdit();
                                drTransDets["StockID"] = myTransDetails.StockID;
                                drTransDets["Qty"]     = myTransDetails.Qty;


                                drTransDets.EndEdit();
                                daTransD.Update(dsKaizen, "TransDetails");
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                            MessageBoxIcon.Error);
                        }
                    }
                }
                if (ogTransDrows < dt.Rows.Count)
                {
                    getTransDetsnum();
                    int utdDetsNumber = seperateNumber(findTransID);

                    // for (int i = 0; i < (dt.Rows.Count - ogTransDrows); i++)
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dt.Rows.IndexOf(dr) < ogTransDrows)
                        {
                        }
                        else
                        {
                            MyTransDetails myTransDetails = new MyTransDetails();

                            utdDetsNumber += 1;

                            TansDIDString = "TD-" + utdDetsNumber;

                            try
                            {
                                myTransDetails.TransDetsID = TansDIDString;
                            }
                            catch (MyException MyEx)
                            {
                                ok = false;
                            }

                            try
                            {
                                myTransDetails.TransID = txtEditOrderID.Text.Trim();
                            }
                            catch (MyException MyEx)
                            {
                                ok = false;
                            }

                            try
                            {
                                myTransDetails.StockID = dr["StockID"].ToString();
                            }
                            catch (MyException MyEx)
                            {
                                ok = false;
                            }

                            try
                            {
                                myTransDetails.Qty = Convert.ToInt32(dr["Qty"]);
                            }
                            catch (MyException MyEx)
                            {
                                ok = false;
                            }

                            if (ok)
                            {
                                drTransDets = dsKaizen.Tables["TransDetails"].NewRow();

                                drTransDets["TransDetsID"] = myTransDetails.TransDetsID;
                                drTransDets["TransID"]     = myTransDetails.TransID;
                                drTransDets["StockID"]     = myTransDetails.StockID;
                                drTransDets["Qty"]         = myTransDetails.Qty;
                                drTransDets["StartDate"]   = DBNull.Value;
                                drTransDets["EndDate"]     = DBNull.Value;

                                dsKaizen.Tables["TransDetails"].Rows.Add(drTransDets);

                                new SqlCommandBuilder(daTransD);
                                daTransD.Update(dsKaizen, "TransDetails");
                            }
                        }
                    }
                }
                MyTrans myTrans = new MyTrans();

                errP.Clear();

                drTrans = dsKaizen.Tables["Trans"].Rows.Find(txtEditOrderID.Text);

                try
                {
                    myTrans.CustID = txtEditCustID.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEditCustID, MyEx.toString());
                }

                try
                {
                    myTrans.TransOn = dtpEditDate.Value;
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(dtpEditDate, MyEx.toString());
                }

                try
                {
                    myTrans.TransTotal = Convert.ToDouble(lblEditTCost.Text.Trim());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(lblEditTCost, MyEx.toString());
                }
                try
                {
                    myTrans.BalOwed = Convert.ToDouble(lblEditOutstanding.Text.Trim());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(lblEditOutstanding, MyEx.toString());
                }

                try
                {
                    if (ok)
                    {
                        drTrans.BeginEdit();
                        drTrans["CustID"]      = myTrans.CustID;
                        drTrans["TransDate"]   = myTrans.TransOn;
                        drTrans["TransTotal"]  = myTrans.TransTotal;
                        drTrans["BalanceOwed"] = myTrans.BalOwed;

                        if (myTrans.BalOwed <= 0)
                        {
                            drTrans["Paid"] = 'Y';
                        }
                        else
                        {
                            drTrans["Paid"] = 'N';
                        }

                        drTrans.EndEdit();
                        daTrans.Update(dsKaizen, "Trans");

                        MessageBox.Show("Purchase Details Updated", "Order");

                        disableEdittxtB();

                        btnEditTrans.Text      = "EDIT ORDER";
                        tabEquip.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                    MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 19
0
        private void picBookingSave_Click(object sender, EventArgs e)
        {
            MyBooking myBook = new MyBooking();
            bool      ok     = true;

            errP.Clear();

            //Booking Number
            try
            {
                myBook.BookingNumber = lblBookingNo.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblBookingNo, MyEx.toString());
            }

            ////Booking Type
            //try
            //{
            //    myBook.TypeID = "TYP100001";
            //}
            //catch (MyException MyEx)
            //{
            //    ok = false;
            //    errP.SetError(lblBookingType, MyEx.toString());
            //}

            //Check In Date
            try
            {
                myBook.CheckInDate = dtpBookingCheckIn.Value;
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(dtpBookingCheckIn, MyEx.toString());
            }

            //Check Out Date
            try
            {
                myBook.CheckOutDate = dtpBookingCheckOut.Value;
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(dtpBookingCheckOut, MyEx.toString());
            }

            //Check In Time
            try
            {
                myBook.BookingTime = "13:00";
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblCheckInTime, MyEx.toString());
            }

            //Customer Number
            try
            {
                myBook.CustomerNumber = cmbCustomerNo.SelectedValue.ToString();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmbCustomerNo, MyEx.toString());
            }

            //Payment Type
            try
            {
                myBook.PaymentTypeID = cmbPayType.SelectedValue.ToString();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmbPayType, MyEx.toString());
            }

            //Party Size
            try
            {
                checkMaxCap();

                if (int.Parse(txtPartySize.Text.Trim()) <= MainWindow.maxCap && int.Parse(txtPartySize.Text.Trim()) > 0)
                {
                    myBook.PartySize = int.Parse(txtPartySize.Text.Trim());
                }
                else
                {
                    ok = false;
                    errP.SetError(txtPartySize, "Party size must not exceed the capacity of the room, please enter a value of " + (MainWindow.maxCap) + " or less. Alternatively cancel and select a larger room.");
                }
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPartySize, MyEx.toString());
            }

            //Try Adding
            try
            {
                if (ok)
                {
                    drBooking.BeginEdit();
                    drBooking["checkInDate"]  = myBook.CheckInDate;
                    drBooking["checkOutDate"] = myBook.CheckOutDate;
                    drBooking["bookingTime"]  = myBook.BookingTime;
                    //drBooking["typeID"] = myBook.TypeID;
                    drBooking["paymentTypeID"] = myBook.PaymentTypeID;
                    //drBooking["roomNo"] = myBook.RoomNo;
                    //drBooking["tableNo"] = myBook.TableNo;
                    drBooking["partySize"]  = myBook.PartySize;
                    drBooking["customerNo"] = myBook.CustomerNumber;
                    drBooking.EndEdit();
                    daBooking.Update(dsBelfray, "Booking");

                    MessageBox.Show("Booking Updated");

                    cancelled = true;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 20
0
        private void picCustomerSave_Click(object sender, EventArgs e)
        {
            MyCustomer myCust = new MyCustomer();
            bool       ok     = true;

            errP.Clear();

            //Customer Number
            try
            {
                myCust.CustomerNumber = lblCustNo.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblCustNo, MyEx.toString());
            }

            //Customer Title
            try
            {
                myCust.Title = cmbTitle.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmbTitle, MyEx.toString());
            }

            //Customer Forename
            try
            {
                myCust.Forename = txtForename.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtForename, MyEx.toString());
            }

            //Customer Surname
            try
            {
                myCust.Surname = txtSurname.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSurname, MyEx.toString());
            }

            //Customer Street
            try
            {
                myCust.Street = txtStreet.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtStreet, MyEx.toString());
            }

            //Customer City
            try
            {
                myCust.City = txtCity.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtCity, MyEx.toString());
            }

            //Customer County
            try
            {
                myCust.County = txtCounty.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtCounty, MyEx.toString());
            }

            //Customer PostCode
            try
            {
                myCust.Postcode = txtPostcode.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPostcode, MyEx.toString());
            }

            //Customer TelNo
            try
            {
                myCust.TelNo = txtPhoneNo.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPhoneNo, MyEx.toString());
            }

            //Try Adding
            try
            {
                if (ok)
                {
                    drCustomer.BeginEdit();
                    drCustomer["customerForename"] = myCust.Title;
                    drCustomer["customerForename"] = myCust.Forename;
                    drCustomer["customerSurname"]  = myCust.Surname;
                    drCustomer["customerStreet"]   = myCust.Street;
                    drCustomer["customerCity"]     = myCust.City;
                    drCustomer["customerCounty"]   = myCust.County;
                    drCustomer["customerPostcode"] = myCust.Postcode;
                    drCustomer["customerTel"]      = myCust.TelNo;
                    drCustomer.EndEdit();
                    daCustomer.Update(dsBelfray, "Customer");

                    MessageBox.Show("Customer Updated");

                    disableCustomerEdit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 21
0
        private void btnAAStaff_Click(object sender, EventArgs e)
        {
            MyStaff myStaff = new MyStaff();
            bool    ok      = true;

            errP.Clear();
            try
            {
                myStaff.StaffID = lblAddStaffID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblAddStaffID, MyEx.toString());
            }

            try
            {
                myStaff.Email = txtAEmail.Text.Trim();
            }

            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAEmail, MyEx.toString());
            }

            try
            {
                myStaff.Forename = txtAForeN.Text.Trim();
            }

            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAForeN, MyEx.toString());
            }


            try
            {
                myStaff.TelNo = txtATel.Text.Trim();
            }

            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtATel, MyEx.toString());
            }

            try
            {
                myStaff.Job = cmbAJr.Text.Trim();
            }

            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmbAJr, MyEx.toString());
            }

            try
            {
                myStaff.Surname = txtASurN.Text.Trim();
            }

            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtASurN, MyEx.toString());
            }
            try
            {
                myStaff.JobDescription = txtAJobDesc.Text.Trim();
            }

            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAJobDesc, MyEx.toString());
            }


            try
            {
                if (ok)
                {
                    drStaff               = dsKaizen.Tables["Staff"].NewRow();
                    drStaff["StaffID"]    = myStaff.StaffID;
                    drStaff["StaffFName"] = myStaff.Forename;
                    drStaff["StaffSName"] = myStaff.Surname;
                    drStaff["Job"]        = myStaff.Job;
                    drStaff["JobDesc"]    = myStaff.JobDescription;
                    drStaff["StaffEmail"] = myStaff.Email;
                    drStaff["StaffTel"]   = myStaff.TelNo;

                    dsKaizen.Tables["Staff"].Rows.Add(drStaff);
                    daStaff.Update(dsKaizen, "Staff");

                    MessageBox.Show("Employee Added");

                    if (MessageBox.Show("Do you wish to add another Employee?", "Add Employee", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        clearAddForm();

                        getStaffID(dsKaizen.Tables["Staff"].Rows.Count);
                    }
                    else
                    {
                        tabStaff.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                MessageBoxIcon.Error);
            }
        }
Esempio n. 22
0
        private void btnEdEdit_Click(object sender, EventArgs e)
        {
            if (btnEdEdit.Text.Trim() == "EDIT")
            {
                enableEditTxtboxes();
                btnEdEdit.Text = "Save";
            }
            else
            {
                MyStaff myStaff = new MyStaff();
                bool    ok      = true;
                errP.Clear();
                try
                {
                    myStaff.StaffID = lblEdStaffID.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(lblEdStaffID, MyEx.toString());
                }

                try
                {
                    myStaff.Email = txtEdEmail.Text.Trim();
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEdEmail, MyEx.toString());
                }

                try
                {
                    myStaff.Forename = txtEdForeN.Text.Trim();
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEdForeN, MyEx.toString());
                }
                try
                {
                    myStaff.TelNo = txtEdTel.Text.Trim();
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEdTel, MyEx.toString());
                }
                try
                {
                    myStaff.Job = txtEdJobR.Text.Trim();
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEdJobR, MyEx.toString());
                }

                try
                {
                    myStaff.Surname = txtEdSurN.Text.Trim();
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEdSurN, MyEx.toString());
                }
                try
                {
                    myStaff.JobDescription = txtEdJobDesc.Text.Trim();
                }

                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtEdJobDesc, MyEx.toString());
                }
                try
                {
                    if (ok)
                    {
                        drStaff.BeginEdit();

                        drStaff["StaffID"]    = myStaff.StaffID;
                        drStaff["StaffFName"] = myStaff.Forename;
                        drStaff["StaffSName"] = myStaff.Surname;
                        drStaff["Job"]        = myStaff.Job;
                        drStaff["JobDesc"]    = myStaff.JobDescription;
                        drStaff["StaffEmail"] = myStaff.Email;
                        drStaff["StaffTel"]   = myStaff.TelNo;

                        drStaff.EndEdit();
                        daStaff.Update(dsKaizen, "Staff");

                        btnEdEdit.Text = "EDIT";

                        MessageBox.Show("Employee Details Updated", "Staff");



                        tabStaff.SelectedIndex = 0;

                        disableEditTxtboxes();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                    MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 23
0
        private void picStaffSave_Click(object sender, EventArgs e)
        {
            foreach (DataRow drStaff in dsBelfray.Tables["Staff"].Rows)
            {
                if (drStaff["staffID"].ToString().Equals(lblStaffNo.Text))
                {
                    MyStaff myStaff = new MyStaff();
                    bool    ok      = true;
                    errP.Clear();

                    //Forename
                    try
                    {
                        myStaff.Forename = txtForename.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtForename, MyEx.toString());
                    }

                    //Surname
                    try
                    {
                        myStaff.Surname = txtSurname.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtSurname, MyEx.toString());
                    }

                    //Street
                    try
                    {
                        myStaff.Street = txtStreet.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtStreet, MyEx.toString());
                    }

                    //City
                    try
                    {
                        myStaff.City = txtCity.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtCity, MyEx.toString());
                    }

                    //County
                    try
                    {
                        myStaff.County = txtCounty.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtCounty, MyEx.toString());
                    }

                    //Postcode
                    try
                    {
                        myStaff.Postcode = txtPostcode.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtPostcode, MyEx.toString());
                    }

                    //Tel No
                    try
                    {
                        myStaff.TelNo = txtPhoneNo.Text.ToString();
                    }
                    catch (MyException MyEx)
                    {
                        ok = false;
                        errP.SetError(txtPhoneNo, MyEx.toString());
                    }

                    //Try Adding
                    try
                    {
                        if (ok)
                        {
                            int    length      = txtSurname.Text.ToString().Length;
                            string lastInitial = txtSurname.Text.ToString().Substring(0, 1);
                            string lName       = txtSurname.Text.ToString().Substring(1, length - 1);
                            char[] fName       = txtForename.Text.ToString().ToCharArray();
                            string initial     = fName[0].ToString().ToUpper();
                            lblLogin.Text = lastInitial.ToUpper() + lName + initial;

                            drStaff.BeginEdit();
                            drStaff["staffFName"]  = myStaff.Forename;
                            drStaff["staffLName"]  = myStaff.Surname;
                            drStaff["staffStreet"] = myStaff.Street;
                            drStaff["staffCity"]   = myStaff.City;
                            drStaff["staffCounty"] = myStaff.County;
                            drStaff["staffPcode"]  = myStaff.Postcode;
                            drStaff["staffTelNo"]  = myStaff.TelNo;
                            drStaff["staffLogin"]  = lblLogin.Text.ToString();
                            drStaff.EndEdit();
                            daStaff.Update(dsBelfray, "Staff");

                            MessageBox.Show("User Info Updated");

                            picStaffCancel.Visible = false;
                            picStaffSave.Visible   = false;
                            picStaffEdit.Visible   = true;

                            txtForename.Enabled = false;
                            txtSurname.Enabled  = false;
                            txtStreet.Enabled   = false;
                            txtCity.Enabled     = false;
                            txtCounty.Enabled   = false;
                            txtPostcode.Enabled = false;
                            txtPhoneNo.Enabled  = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                    }
                }
            }
        }
Esempio n. 24
0
        private void btnConfirmAddSupplier_Click(object sender, EventArgs e)
        {
            MySupplier mySupplier = new MySupplier();
            bool       ok         = true;

            errorProvider1.Clear();

            try
            {
                mySupplier.SupplierNo = lblAddActualSupplierNo.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errorProvider1.SetError(lblAddActualSupplierNo, MyEx.toString());
            }

            try
            {
                mySupplier.Name = txtAddSupplierName.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errorProvider1.SetError(txtAddSupplierName, MyEx.toString());
            }

            try
            {
                mySupplier.Street = txtAddSupplierStreet.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errorProvider1.SetError(txtAddSupplierStreet, MyEx.toString());
            }

            try
            {
                mySupplier.Town = txtAddSupplierTown.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errorProvider1.SetError(txtAddSupplierTown, MyEx.toString());
            }

            try
            {
                mySupplier.County = txtAddSupplierCounty.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errorProvider1.SetError(txtAddSupplierCounty, MyEx.toString());
            }

            try
            {
                mySupplier.Postcode = txtAddSupplierPostcode.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errorProvider1.SetError(txtAddSupplierPostcode, MyEx.toString());
            }

            try
            {
                mySupplier.TelephoneNo = txtAddSupplierTelephoneNo.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errorProvider1.SetError(txtAddSupplierTelephoneNo, MyEx.toString());
            }
            try
            {
                mySupplier.Email = txtAddSupplierEmail.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errorProvider1.SetError(txtAddSupplierEmail, MyEx.toString());
            }

            try
            {
                if (ok)
                {
                    drSupplier = dsSurefill.Tables["Supplier"].NewRow();

                    drSupplier["SupplierNo"]  = mySupplier.SupplierNo;
                    drSupplier["Name"]        = mySupplier.Name;
                    drSupplier["Street"]      = mySupplier.Street;
                    drSupplier["Town"]        = mySupplier.Town;
                    drSupplier["County"]      = mySupplier.County;
                    drSupplier["Postcode"]    = mySupplier.Postcode;
                    drSupplier["Email"]       = mySupplier.Email;
                    drSupplier["TelephoneNo"] = mySupplier.TelephoneNo;


                    dsSurefill.Tables["Supplier"].Rows.Add(drSupplier);
                    daSupplier.Update(dsSurefill, "Supplier");

                    MessageBox.Show("Supplier Added");

                    if (MessageBox.Show("Do you want to add another Supplier?", "Add Supplier", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        clearAddForm();

                        getNumber(dsSurefill.Tables["Supplier"].Rows.Count);
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 25
0
 public static int Extr(int x, int y, MyEx mX)
 {
     return(mX(x, y));
 }
Esempio n. 26
0
        private void btn_AddUser_Click(object sender, EventArgs e)
        {
            MyUser myUser = new MyUser();
            bool   ok     = true;

            errP.Clear();

            try
            {
                myUser.UserID = Convert.ToInt32(lbl_UserNoText.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lbl_UserNoText, MyEx.tostring());
            }

            try
            {
                myUser.Username = txt_Username.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_Username, MyEx.tostring());
            }

            try
            {
                myUser.UserForename = txt_UserForename.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_UserForename, MyEx.tostring());
            }

            try
            {
                myUser.UserSurname = txt_UserSurname.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_UserSurname, MyEx.tostring());
            }

            try
            {
                myUser.UserLevel = txt_UserLevel.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_UserLevel, MyEx.tostring());
            }

            try
            {
                myUser.UserPassword = txt_UserPass.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_UserPass, MyEx.tostring());
            }

            try
            {
                myUser.UserEmail = txt_UserEmail.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txt_UserEmail, MyEx.tostring());
            }

            try
            {
                if (chk_Super.Checked)
                {
                    myUser.Super = "Y";
                }
                else
                {
                    myUser.Super = "N";
                }
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(chk_Super, MyEx.tostring());
            }

            try
            {
                if (ok)
                {
                    drUser                 = dsNWRC_HairBeauty.Tables["UserLogin"].NewRow();
                    drUser["UserID"]       = myUser.UserID;
                    drUser["Username"]     = myUser.Username;
                    drUser["UserSurname"]  = myUser.UserSurname;
                    drUser["UserForename"] = myUser.UserForename;
                    drUser["UserEmail"]    = myUser.UserEmail;
                    drUser["UserLevel"]    = myUser.UserLevel;
                    drUser["Passkey"]      = myUser.UserPassword;
                    drUser["Super"]        = myUser.Super;


                    dsNWRC_HairBeauty.Tables["UserLogin"].Rows.Add(drUser);
                    daUser.Update(dsNWRC_HairBeauty, "UserLogin");

                    MessageBox.Show("New User " + lbl_UserNoText.Text + " added !!!");

                    if (MessageBox.Show("Do you wish to add another User?", "Add User", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        clearAddForm();
                        getNumber(dsNWRC_HairBeauty.Tables["UserLogin"].Rows.Count);
                    }
                    else
                    {
                        tab_User.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 27
0
        private void btnAddCompleteOrder_Click(object sender, EventArgs e)
        {
            MyTrans myTrans = new MyTrans();
            bool    ok      = true;

            errP.Clear();

            try
            {
                myTrans.TransID = lblAddTransID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblAddTransID, MyEx.toString());
            }

            try
            {
                myTrans.CustID = txtAddCustID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAddCustID, MyEx.toString());
            }

            try
            {
                myTrans.TransOn = dtpAddDate.Value;
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(dtpAddDate, MyEx.toString());
            }

            try
            {
                myTrans.TransTotal = Convert.ToDouble(lblAddTCost.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblAddTCost, MyEx.toString());
            }
            catch (FormatException frmex)
            {
                ok = false;
                MessageBox.Show("Please Input Order Details Before Adding", "Order");
            }

            //   try
            {
                if (ok)
                {
                    drTrans                = dsKaizen.Tables["Trans"].NewRow();
                    drTrans["TransID"]     = myTrans.TransID;
                    drTrans["TransType"]   = "Purchase";
                    drTrans["CustID"]      = myTrans.CustID;
                    drTrans["TransDate"]   = myTrans.TransOn;
                    drTrans["TransTotal"]  = myTrans.TransTotal;
                    drTrans["BalanceOwed"] = myTrans.TransTotal;
                    drTrans["Paid"]        = 'N';

                    dsKaizen.Tables["Trans"].Rows.Add(drTrans);
                    daTrans.Update(dsKaizen, "Trans");

                    //                  getTransDetailsID(dsKaizen.Tables["TransDetails"].Rows.Count);
                    getTransDetsnum();
                    int utdDetsNumber = seperateNumber(findTransID);

                    foreach (DataRow dr in dt.Rows)
                    {
                        MyTransDetails myTransDetails = new MyTransDetails();

                        utdDetsNumber += 1;

                        TansDIDString = "TD-" + utdDetsNumber;

                        try
                        {
                            myTransDetails.TransDetsID = TansDIDString;
                        }
                        catch (MyException MyEx)
                        {
                            ok = false;
                        }

                        try
                        {
                            myTransDetails.TransID = lblAddTransID.Text.Trim();
                        }
                        catch (MyException MyEx)
                        {
                            ok = false;
                        }

                        try
                        {
                            myTransDetails.StockID = dr["StockID"].ToString();
                        }
                        catch (MyException MyEx)
                        {
                            ok = false;
                        }

                        try
                        {
                            myTransDetails.Qty = Convert.ToInt32(dr["Qty"]);
                        }
                        catch (MyException MyEx)
                        {
                            ok = false;
                        }

                        if (ok)
                        {
                            drTransDets = dsKaizen.Tables["TransDetails"].NewRow();

                            drTransDets["TransDetsID"] = myTransDetails.TransDetsID;
                            drTransDets["TransID"]     = myTransDetails.TransID;
                            drTransDets["StockID"]     = myTransDetails.StockID;
                            GetCurrentStock(myTransDetails.StockID);
                            drTransDets["Qty"]       = myTransDetails.Qty;
                            drTransDets["StartDate"] = DBNull.Value;
                            drTransDets["EndDate"]   = DBNull.Value;

                            dsKaizen.Tables["TransDetails"].Rows.Add(drTransDets);

                            newQty = currentQty - myTransDetails.Qty;

                            string        constr = @"Data Source = .; Initial Catalog = Kaizen;Integrated Security = true ";
                            SqlConnection con    = new SqlConnection(constr);
                            DataSet       ds     = new DataSet();
                            con.Open();
                            SqlCommand cmd = new SqlCommand(" UPDATE Stock SET QtyInStock = " + newQty + " WHERE StockID ='" + myTransDetails.StockID + "'", con);
                            cmd.ExecuteNonQuery();
                            con.Close();


                            new SqlCommandBuilder(daTransD);
                            daTransD.Update(dsKaizen, "TransDetails");
                        }
                    }


                    MessageBox.Show("Purchase Order Added");

                    if (MessageBox.Show("Do you wish to Make another Order?", "Add Stock", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        clearAddForm();

                        getTransID(dsKaizen.Tables["Trans"].Rows.Count);
                    }
                    else
                    {
                        tabEquip.SelectedIndex = 0;
                    }
                }
            }
            // catch (Exception ex)
            {
                // MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                //   MessageBoxIcon.Error);
            }
        }
Esempio n. 28
0
        //SaveProduct
        private void picSaveAddProdDet_Click(object sender, EventArgs e)
        {
            MyProduct myProduct = new MyProduct();
            bool      ok        = true;

            errP.Clear();

            try
            {
                myProduct.ProductNo = lblProductNumberDisplay.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblProductNumberDisplay, MyEx.toString());
            }
            try
            {
                myProduct.ProductTypeCode = cbTypeCode.SelectedValue.ToString();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cbTypeCode, MyEx.toString());
            }
            try
            {
                myProduct.ProductDesc = txtProdDesc.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtProdDesc, MyEx.toString());
            }
            try
            {
                myProduct.CostPrice = txtCostPrice.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtCostPrice, MyEx.toString());
            }
            try
            {
                myProduct.QtyInStock = txtQTY.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtQTY, MyEx.toString());
            }
            try
            {
                myProduct.PackSize = txtPackSize.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPackSize, MyEx.toString());
            }
            try
            {
                myProduct.ReOrderLvl = txtReOrder.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtReOrder, MyEx.toString());
            }
            try
            {
                myProduct.SupplierID = cbSuppID.SelectedValue.ToString();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cbSuppID, MyEx.toString());
            }

            //Try Adding
            try
            {
                if (ok)
                {
                    drProduct = dsBelfray.Tables["Product"].NewRow();
                    drProduct["productNumber"]   = myProduct.ProductNo;
                    drProduct["productTypeCode"] = myProduct.ProductTypeCode;
                    drProduct["productDesc"]     = myProduct.ProductDesc;
                    drProduct["costPrice"]       = myProduct.CostPrice;
                    drProduct["qtyInStock"]      = myProduct.QtyInStock;
                    drProduct["packSize"]        = myProduct.PackSize;
                    drProduct["reorderLvl"]      = myProduct.ReOrderLvl;
                    drProduct["supplierID"]      = myProduct.SupplierID;

                    dsBelfray.Tables["Product"].Rows.Add(drProduct);
                    daProduct.Update(dsBelfray, "Product");

                    MessageBox.Show("Product Added");

                    if (MessageBox.Show("Do you wish to add another product?", "AddProduct", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        formLoad = true;
                        clearAddPanel();
                        getProdNum(dsBelfray.Tables["Product"].Rows.Count);
                        string s  = drProduct["productNumber"].ToString();
                        string s1 = "PRD" + (Convert.ToInt32(s.Replace("PRD", "")) + 1).ToString().PadLeft(5, '0');
                        lblProductNumberDisplay.Text = s1;
                    }
                    else
                    {
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }
Esempio n. 29
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            MyStock myStock = new MyStock();
            bool    ok      = true;

            errP.Clear();
            try
            {
                myStock.StockID = lblAddStockID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblAddStockID, MyEx.toString());
            }

            try
            {
                myStock.StockDesc = txtAddDesc.Text.Trim();
            }

            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAddDesc, MyEx.toString());
            }

            try
            {
                myStock.QtyInStock = Convert.ToInt32(txtAddQTY.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAddQTY, MyEx.toString());
            }
            catch (FormatException Formex)
            {
                ok = false;
                errP.SetError(txtAddQTY, "Please Enter a vaild number");
            }

            try
            {
                myStock.EquipType = this.cmbAddProdType.GetItemText(this.cmbAddProdType.SelectedItem);
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(cmbAddProdType, MyEx.toString());
            }

            try
            {
                myStock.PurPrice = Convert.ToDouble(txtAddPurchase.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAddPurchase, MyEx.toString());
            }
            catch (FormatException Formex)
            {
                ok = false;
                errP.SetError(txtAddPurchase, "Please Enter a vaild number");
            }

            try
            {
                myStock.RentalPrice = Convert.ToDouble(txtAddRental.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAddRental, MyEx.toString());
            }
            catch (FormatException Formex)
            {
                ok = false;
                errP.SetError(txtAddRental, "Please Enter a vaild number");
            }

            try
            {
                myStock.ServicePrice = Convert.ToDouble(txtAddService.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAddService, MyEx.toString());
            }
            catch (FormatException Formex)
            {
                ok = false;
                errP.SetError(txtAddService, "Please Enter a vaild number");
            }

            try
            {
                myStock.SuppID = txtAddProdSupplierID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtAddProdSupplierID, MyEx.toString());
            }

            try
            {
                if (ok)
                {
                    drStock                     = dsKaizen.Tables["Stock"].NewRow();
                    drStock["StockID"]          = myStock.StockID;
                    drStock["StockDescription"] = myStock.StockDesc;
                    drStock["Equiptype"]        = myStock.EquipType;
                    drStock["PurPrice"]         = myStock.PurPrice;
                    drStock["RentPrice"]        = myStock.RentalPrice;
                    drStock["ServPrice"]        = myStock.ServicePrice;
                    drStock["QtyInStock"]       = myStock.QtyInStock;
                    drStock["SuppID"]           = myStock.SuppID;


                    dsKaizen.Tables["Stock"].Rows.Add(drStock);
                    daStock.Update(dsKaizen, "Stock");

                    MessageBox.Show("Stock Item/s Added");
                    clearAddForm();
                    if (MessageBox.Show("Do you wish to add more stock items?", "Add Stock", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        getStockID(dsKaizen.Tables["Stock"].Rows.Count);
                    }
                    else
                    {
                        tabStock.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                MessageBoxIcon.Error);
            }
        }
Esempio n. 30
0
        private void btnConfirmEditSupplier_Click(object sender, EventArgs e)
        {
            if (btnConfirmEditSupplier.Text == "Edit")
            {
                txtAddSupplierName.Enabled         = true;
                txtEditSupplierStreet.Enabled      = true;
                txtEditSupplierTown.Enabled        = true;
                txtEditSupplierCounty.Enabled      = true;
                txtEditSupplierPostcode.Enabled    = true;
                txtEditSupplierEmail.Enabled       = true;
                txtEditSupplierTelephoneNo.Enabled = true;

                btnConfirmEditSupplier.Text = "Save";
            }
            else
            {
                MySupplier mySupplier = new MySupplier();
                bool       ok         = true;
                errorProvider1.Clear();

                try
                {
                    mySupplier.SupplierNo = lblEditActualSupplierNo.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errorProvider1.SetError(lblEditActualSupplierNo, MyEx.toString());
                }

                try
                {
                    mySupplier.Name = txtEditSupplierName.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errorProvider1.SetError(txtEditSupplierName, MyEx.toString());
                }

                try
                {
                    mySupplier.Street = txtEditSupplierStreet.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errorProvider1.SetError(txtEditSupplierStreet, MyEx.toString());
                }

                try
                {
                    mySupplier.Town = txtEditSupplierTown.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errorProvider1.SetError(txtEditSupplierTown, MyEx.toString());
                }

                try
                {
                    mySupplier.County = txtEditSupplierCounty.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errorProvider1.SetError(txtEditSupplierCounty, MyEx.toString());
                }

                try
                {
                    mySupplier.Postcode = txtEditSupplierPostcode.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errorProvider1.SetError(txtEditSupplierPostcode, MyEx.toString());
                }

                try
                {
                    mySupplier.TelephoneNo = txtEditSupplierTelephoneNo.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errorProvider1.SetError(txtEditSupplierTelephoneNo, MyEx.toString());
                }
                try
                {
                    mySupplier.Email = txtEditSupplierEmail.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errorProvider1.SetError(txtEditSupplierEmail, MyEx.toString());
                }

                try
                {
                    if (ok)
                    {
                        drSupplier.BeginEdit();


                        drSupplier["SupplierNo"]  = mySupplier.SupplierNo;
                        drSupplier["Name"]        = mySupplier.Name;
                        drSupplier["Street"]      = mySupplier.Street;
                        drSupplier["Town"]        = mySupplier.Town;
                        drSupplier["County"]      = mySupplier.County;
                        drSupplier["Postcode"]    = mySupplier.Postcode;
                        drSupplier["Email"]       = mySupplier.Email;
                        drSupplier["TelephoneNo"] = mySupplier.TelephoneNo;

                        drSupplier.EndEdit();
                        daSupplier.Update(dsSurefill, "Supplier");

                        MessageBox.Show("Supplier details updated", "Supplier");

                        txtEditSupplierName.Enabled        = false;
                        txtEditSupplierStreet.Enabled      = false;
                        txtEditSupplierTown.Enabled        = false;
                        txtEditSupplierCounty.Enabled      = false;
                        txtEditSupplierPostcode.Enabled    = false;
                        txtEditSupplierEmail.Enabled       = false;
                        txtEditSupplierTelephoneNo.Enabled = false;

                        btnConfirmEditSupplier.Text = "Edit";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 31
0
        private void picSaveADDSupp_Click(object sender, EventArgs e)
        {
            MySupplier mySupp = new MySupplier();
            bool       ok     = true;

            errP.Clear();

            try
            {
                mySupp.SupplierID = lblSupplierID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblSupplierID, MyEx.toString());
            }
            try
            {
                mySupp.SupplierName = txtSuppName.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSuppName, MyEx.toString());
            }
            try
            {
                mySupp.SupplierAddress = txtSuppAddress.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSuppAddress, MyEx.toString());
            }
            try
            {
                mySupp.SupplierTown = txtSuppTown.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSuppTown, MyEx.toString());
            }
            try
            {
                mySupp.SupplierCounty = txtSuppCounty.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSuppCounty, MyEx.toString());
            }
            try
            {
                mySupp.SupplierPostCode = txtSuppPC.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSuppPC, MyEx.toString());
            }
            try
            {
                mySupp.SupplierEmail = txtSuppEmail.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSuppEmail, MyEx.toString());
            }
            try
            {
                mySupp.SupplierTelNo = txtSuppTel.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtSuppTel, MyEx.toString());
            }

            //Try Adding
            try
            {
                if (ok)
                {
                    drSupplier = dsBelfray.Tables["Supplier"].NewRow();
                    drSupplier["supplierID"]       = mySupp.SupplierID;
                    drSupplier["supplierName"]     = mySupp.SupplierName;
                    drSupplier["supplierAddress"]  = mySupp.SupplierAddress;
                    drSupplier["supplierTown"]     = mySupp.SupplierTown;
                    drSupplier["supplierCounty"]   = mySupp.SupplierCounty;
                    drSupplier["supplierPostCode"] = mySupp.SupplierPostCode;
                    drSupplier["supplierEmail"]    = mySupp.SupplierEmail;
                    drSupplier["supplierTelNo"]    = mySupp.SupplierTelNo;
                    dsBelfray.Tables["Supplier"].Rows.Add(drSupplier);
                    daSupplier.Update(dsBelfray, "Supplier");

                    MessageBox.Show("Supplier Added");
                    if (MessageBox.Show("Do you wish to add another Supplier?", "AddSupplier", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        clearSuppPanel();
                        test = true;
                    }
                    else
                    {
                        pnlSuppDetails.Enabled = false;
                        pnlDetails.Enabled     = true;
                        clearSuppPanel();
                        test = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            }
        }