private void buttonSave_Click(object sender, EventArgs e)
 {
     if (textBoxDetailsCustomerName.Text == String.Empty)
     {
         labelName.ForeColor = Color.Red;
         return;
     }
     localInterface.Insert("customers", "name,city,address,zipCode,poBox,phoneNumber,fax,eMail,contactPerson,notes",
                           textBoxDetailsCustomerName.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerCity.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerAddress.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerZip.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerPO.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerPhone.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerFax.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerEmail.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerContactPerson.Text.Replace("'", "\\'") + "','" +
                           textBoxDetailsCustomerNotes.Text.Replace("'", "\\'"));
     MessageBox.Show("לקוח חדש נשמר במערכת", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
     this.Close();
     if (formSelectCustomer != null)
     {
         formSelectCustomer.refreshAndfillSearchTextBox(textBoxDetailsCustomerName.Text);
     }
     try
     {
         this.mainForm.refreshView();
     }
     catch { }
 }
Esempio n. 2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (textBoxText.Text == String.Empty)
            {
                labelText.ForeColor = Color.Red;
                return;
            }
            textBoxText.Text = textBoxText.Text.Replace(@"\", @"\\").Replace("'", @"\'").Replace('"', '\"');
            string date = MyUtills.dateToSQL(DateTime.Now) + " " + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();

            localInterface.Insert("notes", "idBill,name,date,text", idBill + "','" +
                                  textBoxName.Text + "','" +
                                  date + "','" +
                                  textBoxText.Text);
            MessageBox.Show("הודעת מעקב חדשה נשמרה במערכת", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
            mainForm.refreshBillNotes(idBill);
            this.Close();
        }
Esempio n. 3
0
        private void labelUpdateVat_Click(object sender, EventArgs e)
        {
            DataTable dt          = new DataTable();
            double    newVat      = 0;
            string    inputNewVat = textBoxNewVat.Text;

            if (inputNewVat == "")
            {
                inputNewVat = "0";
            }
            if (!Double.TryParse(inputNewVat, out newVat))
            {
                MessageBox.Show("מע\"מ לא חוקי", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                return;
            }
            String newDateFormatted = MyUtills.dateToSQL(dateTimePickerNewVat.Value);

            //String newDate = dateTimePickerNewVat.Value.ToShortDateString();
            //String newDateFormatted = newDate.Substring(6,4) + "-" + newDate.Substring(3,2) + "-" + newDate.Substring(0,2);
            dt = localInterface.Select("SELECT id FROM vat WHERE date='" + newDateFormatted + "'").Tables[0];
            if (dt.Rows.Count > 0)
            {
                if (inputNewVat != "0")
                {
                    localInterface.Update("UPDATE vat SET vat='" + inputNewVat + "' WHERE date='" + newDateFormatted + "'");
                }
                else
                {
                    localInterface.Update("DELETE FROM vat WHERE date='" + newDateFormatted + "'");
                }
            }
            else
            {
                if (inputNewVat != "0")
                {
                    localInterface.Insert("vat", "date,vat", newDateFormatted + "','" + newVat);
                }
            }
            showVatDataGridView();
        }
Esempio n. 4
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (textBoxName.Text == String.Empty)
     {
         MessageBox.Show("יש להכניס שם להוספה", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
         return;
     }
     try
     {
         localInterface.Insert("handlers", "name", textBoxName.Text);
         textBoxName.Text = "";
         DataSet ds = localInterface.Select("SELECT * FROM handlers ORDER BY name");
         dataGridViewHandlers.DataSource       = ds.Tables[0];
         dataGridViewHandlers.Columns[0].Width = dataGridViewHandlers.Width - 3;
         data = ds.Tables[0];
         MessageBox.Show("מטפל נוסף למערכת", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
     }
     catch
     {
         MessageBox.Show("מטפל כבר קיים במערכת", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
     }
 }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            labelName.ForeColor          = Color.Black;
            labelProjectNumber.ForeColor = Color.Black;
            labelCustomerName.ForeColor  = Color.Black;
            labelAmount.ForeColor        = Color.Black;
            labelPriceIndex.ForeColor    = Color.Black;

            bool returnFlag = false;

            if (textBoxDetailsProjectName.Text == String.Empty)
            {
                labelName.ForeColor = Color.Red;
                returnFlag          = true;
            }
            if (textBoxDetailsProjectNumber.Text == String.Empty)
            {
                labelProjectNumber.ForeColor = Color.Red;
                returnFlag = true;
            }
            else
            {
                try
                {
                    double.Parse(textBoxDetailsProjectNumber.Text);
                }
                catch
                {
                    labelProjectNumber.ForeColor = Color.Red;
                    returnFlag = true;
                }
                DataTable tempNumbersTable;
                tempNumbersTable = localInterface.Select("SELECT projectNumber FROM projects WHERE projectNumber LIKE '%" + textBoxDetailsProjectNumber.Text + "%'").Tables[0];
                if (tempNumbersTable.Rows.Count > 0)
                {
                    double temp = 0;
                    foreach (DataRow row in tempNumbersTable.Rows)
                    {
                        if (double.Parse(row[0].ToString()) > temp)
                        {
                            temp = double.Parse(row[0].ToString());
                        }
                    }
                    textBoxDetailsProjectNumber.Text = (temp + 0.1).ToString();
                    MessageBox.Show("מספר פרוייקט כבר קיים," + "\r\n" + "המספר הוחלף במספר עוקב," + "\r\n" + "באפשרותך לשנותו או לשמור שנית", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                    labelProjectNumber.ForeColor = Color.Red;
                    returnFlag = true;
                }
            }
            if (textBoxDetailsProjectCustomerName.Text == String.Empty)
            {
                labelCustomerName.ForeColor = Color.Red;
                returnFlag = true;
            }
            try
            {
                double.Parse(textBoxDetailsProjectAmount.Text);
            }
            catch
            {
                labelAmount.ForeColor            = Color.Red;
                textBoxDetailsProjectAmount.Text = "0";
                returnFlag = true;
            }
            try
            {
                Double.Parse(textBoxDetailsProjectPriceIndex.Text);
            }
            catch
            {
                labelPriceIndex.ForeColor            = Color.Red;
                textBoxDetailsProjectPriceIndex.Text = "0";
                returnFlag = true;
            }
            if (returnFlag)
            {
                return;
            }
            short contract = 0;

            if (checkBoxDetailsProjectContract.Checked)
            {
                contract = 1;
            }
            short isClosed = 0;

            if (checkBoxDetailsProjectIsClosed.Checked)
            {
                isClosed = 1;
            }
            short projectType = 0;

            if (radioButtonProjectTypeInstilation.Checked)
            {
                projectType = 1;
            }
            localInterface.Insert("projects", "projectNumber,handler1,handler2,startDate,idCustomer,projectName,amount,curency,amountInfo,linking,priceIndex,contract,contractNotes," +
                                  "projectNotes,isClosed,archiveLocation,contractNumber,mileStones,projectType,approverName,approverPhone,approverEmail,approverFax," +
                                  "payerName,payerPhone,payerEmail,payerFax,payerAddress,approverAddress",
                                  textBoxDetailsProjectNumber.Text.Replace("'", "\\'") + "','" +
                                  comboBoxDetailsProjectHandler1.Text.Replace("'", "\\'") + "','" +
                                  comboBoxDetailsProjectHandler2.Text.Replace("'", "\\'") + "','" +
                                  MyUtills.dateToSQL(dateTimePickerDetailsProjectStart.Value) + "','" +
                                  textBoxCustomerId.Text + "','" +
                                  textBoxDetailsProjectName.Text.Replace("'", "\\'") + "','" +
                                  textBoxDetailsProjectAmount.Text + "','" +
                                  comboBoxCurency.SelectedIndex.ToString() + "','" +
                                  textBoxDetailsProjectAmountInfo.Text.Replace("'", "\\'") + "','" +
                                  comboBoxDetailsProjectlinking.SelectedIndex.ToString() + "','" +
                                  textBoxDetailsProjectPriceIndex.Text + "','" +
                                  contract.ToString() + "','" +
                                  textBoxDetailsProjectContractNotes.Text.Replace("'", "\\'") + "','" +
                                  textBoxDetailsProjectNotes.Text.Replace("'", "\\'") + "','" +
                                  isClosed.ToString() + "','" +
                                  textBoxDetailsProjectArchiveLocation.Text.Replace("'", "\\'") + "','" +
                                  textBoxDetailsProjectContractNumber.Text.Replace("'", "\\'") + "','" +
                                  textBoxDetailsProjectMileStones.Text.Replace("'", "\\'") + "','" +
                                  projectType.ToString() + "','" +
                                  textBoxApproverName.Text.Replace("'", "\\'") + "','" +
                                  textBoxApproverPhone.Text + "','" +
                                  textBoxApproverEmail.Text + "','" +
                                  textBoxApproverFax.Text + "','" +
                                  textBoxPayerName.Text.Replace("'", "\\'") + "','" +
                                  textBoxPayerPhone.Text + "','" +
                                  textBoxPayerEmail.Text + "','" +
                                  textBoxPayerFax.Text + "','" +
                                  textBoxPayerAddress.Text.Replace("'", "\\'") + "','" +
                                  textBoxApproverAddress.Text.Replace("'", "\\'"));
            if (dateTimePickerDetailsProjectPriceIndexDate.Checked)
            {
                localInterface.Update("UPDATE projects SET priceIndexDate = '" + MyUtills.dateToSQL(dateTimePickerDetailsProjectPriceIndexDate.Value) +
                                      "' WHERE projectNumber = '" + textBoxDetailsProjectNumber.Text + "' AND projectName = '" + textBoxDetailsProjectName.Text + "'");
            }
            else
            {
                localInterface.Update("UPDATE projects SET priceindexDate = NULL WHERE projectNumber = '" + textBoxDetailsProjectNumber.Text + "' AND projectName = '" + textBoxDetailsProjectName.Text + "'");
            }
            MessageBox.Show("פרוייקט חדש נשמר במערכת", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
            this.Close();
            mainForm.refreshView();
        }
Esempio n. 6
0
        private bool Save()
        {
            labelBillNumber.ForeColor     = Color.Black;
            labelProjectNumber.ForeColor  = Color.Black;
            labelProjectName.ForeColor    = Color.Black;
            buttonSelectProject.ForeColor = Color.Black;
            labelAmount.ForeColor         = Color.Black;
            labelPaid.ForeColor           = Color.Black;
            labelPayMethod.ForeColor      = Color.Black;
            labelCurencyRate.ForeColor    = Color.Black;
            labelBillIncrease.ForeColor   = Color.Black;
            labelBillIndex.ForeColor      = Color.Black;
            labelBillPart.ForeColor       = Color.Black;

            bool returnFlag = false;

            if (textBoxDetailsBillNumber.Text == String.Empty)
            {
                labelBillNumber.ForeColor     = Color.Red;
                labelProjectNumber.ForeColor  = Color.Red;
                labelProjectName.ForeColor    = Color.Red;
                buttonSelectProject.ForeColor = Color.Red;
                returnFlag = true;
            }
            try
            {
                double.Parse(textBoxDetailsBillAmount.Text);
            }
            catch
            {
                labelAmount.ForeColor = Color.Red;
                returnFlag            = true;
            }
            try
            {
                double.Parse(textBoxBillIncrease.Text);
            }
            catch
            {
                labelBillIncrease.ForeColor = Color.Red;
                returnFlag = true;
            }
            try
            {
                double.Parse(textBoxBillIndex.Text);
            }
            catch
            {
                labelBillIndex.ForeColor = Color.Red;
                returnFlag = true;
            }
            try
            {
                double.Parse(textBoxCurencyRate.Text);
                if (double.Parse(textBoxCurencyRate.Text) == 0)
                {
                    textBoxCurencyRate.Text = "1";
                }
            }
            catch
            {
                labelCurencyRate.ForeColor = Color.Red;
                returnFlag = true;
            }
            try
            {
                int.Parse(textBoxBillPart.Text);
            }
            catch
            {
                labelBillPart.ForeColor = Color.Red;
                returnFlag = true;
            }
            short isClosed = 0;

            if (returnFlag)
            {
                return(false);
            }
            if (checkBoxDetailsBillIsClosed.Checked)
            {
                isClosed = 1;
            }
            int  billPart = GetBillPart();//localInterface.Select("SELECT idBill FROM bills WHERE idProject=" + textBoxID.Text).Tables[0].Rows.Count + 1;
            bool queryOk;

            queryOk = localInterface.Insert("bills", "idBill,amount,paid,payMethod,billDate,vatDate,approvalDate,toPayDate,payDate,invoiceNumber,receiptNumber,isClosed,curencyRate,handler,billNotes,increase,billPart,currentIndex,callback",
                                            textBoxDetailsBillNumber.Text + "','" +
                                            textBoxDetailsBillAmount.Text.Replace(",", "") + "','" +
                                            textBoxDetailsBillPaid.Text.Replace(",", "") + "','" +
                                            comboBoxDetailsBillPayMethod.SelectedIndex + "','" +
                                            MyUtills.dateToSQL(dateTimePickerDetailsBillDate.Value) + "','" +
                                            MyUtills.dateToSQL(dateTimePickerDetailsBillDate.Value) + "','" +
                                            MyUtills.dateToSQL(dateTimePickerDetailsBillApproval.Value) + "','" +
                                            MyUtills.dateToSQL(dateTimePickerDetailsBillToPay.Value) + "','" +
                                            MyUtills.dateToSQL(dateTimePickerDetailsBillPay.Value) + "','" +
                                            textBoxDetailsBillInvoiceNumber.Text + "','" +
                                            textBoxDetailsBillReceiptNumber.Text + "','" +
                                            isClosed.ToString() + "','" +
                                            textBoxCurencyRate.Text + "','" +
                                            comboBoxDetailsBillHandlers.SelectedItem + "','" +
                                            textBoxBillNotes.Text.Replace("'", "\\'") + "','" +
                                            textBoxBillIncrease.Text + "','" +
                                            textBoxBillPart.Text + "','" +
                                            textBoxBillIndex.Text + "','" +
                                            MyUtills.dateToSQL(dateTimePickerDetailsBillDate.Value.AddDays(2)));


            if (!queryOk)
            {
                MessageBox.Show("שמירת חשבון חדש נכשלה", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
                return(false);
            }
            else
            {
                int       maxBillId = (int)localInterface.Select("SELECT MAX(id) FROM bills").Tables[0].Rows[0][0];
                DataTable dtProject;
                Double    projectAmount;
                double    projectToSubmit;
                double    oldProgress = 0;
                for (int i = 0; i < dataGridViewProjects.RowCount; i++)
                {
                    dtProject       = localInterface.Select("SELECT projects.amount,projects.toSubmit,COALESCE(SUM(bills_projects.percent),0) FROM projects LEFT JOIN bills_projects ON projects.idProjects=bills_projects.idProject WHERE projects.idProjects=" + dataGridViewProjects.Rows[i].Cells[0].Value.ToString() + " ORDER BY bills_projects.progress DESC LIMIT 1").Tables[0];
                    projectAmount   = Convert.ToDouble(dtProject.Rows[0][0]);
                    projectToSubmit = Convert.ToDouble(dtProject.Rows[0][1]);
                    try
                    {
                        oldProgress = Convert.ToDouble(dtProject.Rows[0][2]);
                    }
                    catch { }
                    localInterface.Insert("bills_projects", "idBill,idProject,percent,progress,paid", maxBillId.ToString() + "','" +
                                          dataGridViewProjects.Rows[i].Cells[0].Value.ToString() + "','" +
                                          (Convert.ToDouble(dataGridViewProjects.Rows[i].Cells[2].Value) / projectAmount * 100).ToString() + "','" +
                                          (oldProgress + Convert.ToDouble(dataGridViewProjects.Rows[i].Cells[2].Value) / projectAmount * 100).ToString() + "','" +
                                          (Convert.ToDouble(dataGridViewProjects.Rows[i].Cells[3].Value) / projectAmount * 100)).ToString();
                    if (projectToSubmit != oldProgress + Convert.ToDouble(dataGridViewProjects.Rows[i].Cells[2].Value) / projectAmount * 100)
                    {
                        localInterface.Update("UPDATE projects SET toSubmit=" + (oldProgress + Convert.ToDouble(dataGridViewProjects.Rows[i].Cells[2].Value) / projectAmount * 100).ToString() + " WHERE idProjects=" + dataGridViewProjects.Rows[i].Cells[0].Value.ToString());
                    }
                }

                //for (int i=0;i<projectIds.Count;i++)
                //    localInterface.Insert("bills_projects", "idBill,idProject,percent,progress", maxBillId.ToString() + "','" +
                //                                                                        projectIds[i].ToString() + "','" +
                //                                                                        projectProgress[i].ToString() + "','" +
                //                                                                        progress[i].ToString());
            }
            if (dateTimePickerDetailsBillApproval.Checked)
            {
                localInterface.Update("UPDATE bills SET approvalDate = '" + MyUtills.dateToSQL(dateTimePickerDetailsBillApproval.Value) +
                                      "' WHERE idBill = '" + textBoxDetailsBillNumber.Text + "'");
            }
            else
            {
                localInterface.Update("UPDATE bills SET approvalDate = NULL WHERE idBill = '" + textBoxDetailsBillNumber.Text + "'");
            }
            if (dateTimePickerDetailsBillToPay.Checked)
            {
                localInterface.Update("UPDATE bills SET toPayDate = '" + MyUtills.dateToSQL(dateTimePickerDetailsBillToPay.Value) +
                                      "' WHERE idBill = '" + textBoxDetailsBillNumber.Text + "'");
            }
            else
            {
                localInterface.Update("UPDATE bills SET toPayDate = NULL WHERE idBill = '" + textBoxDetailsBillNumber.Text + "'");
            }
            if (dateTimePickerDetailsBillPay.Checked)
            {
                localInterface.Update("UPDATE bills SET payDate = '" + MyUtills.dateToSQL(dateTimePickerDetailsBillPay.Value) +
                                      "' WHERE idBill = '" + textBoxDetailsBillNumber.Text + "'");
            }
            else
            {
                localInterface.Update("UPDATE bills SET payDate = NULL WHERE idBill = '" + textBoxDetailsBillNumber.Text + "'");
            }
            MessageBox.Show("חשבון חדש נשמר במערכת", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);
            this.Close();
            mainForm.refreshView();
            return(true);
        }