Beispiel #1
0
 private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (textBoxEdit.Text == "")
     {
         MessageBox.Show("יש להזין שם לספק", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading);
         return;
     }
     localInterface.Update("UPDATE suppliers SET name='" + textBoxEdit.Text.Replace("'", "\\'") + "' WHERE id='" + dataGridViewSuppliers.SelectedRows[0].Cells[0].Value.ToString() + "'");
     showSuppliers("");
 }
Beispiel #2
0
        private void buttonYes_Click(object sender, EventArgs e)
        {
            DateTime newDate = dateTimePicker1.Value;

            if (this.definite)
            {
                localInterface.Update("UPDATE bills SET payDate='" + MyUtills.dateToSQL(newDate) + "' WHERE id=" + this.id);
            }
            else
            {
                localInterface.Update("UPDATE bills SET toPayDate='" + MyUtills.dateToSQL(newDate) + "' WHERE id=" + this.id);
            }
            this.Close();
            mainForm.showFinance();
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            string input = textBoxMain.Text.Replace(@"\", @"\\").Replace("'", @"\'").Replace('"', '\"');
            string query = "UPDATE notes SET text ='" + input + "' WHERE idNotes='" + id + "'";

            interf.Update(query);
            this.Close();
            mainForm.refreshView();
        }
        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();
        }
Beispiel #5
0
        private void dataGridViewExpenses_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            double   amount;
            DateTime date;
            int      approved = 0;

            if (!DateTime.TryParse(dataGridViewExpenses.Rows[e.RowIndex].Cells[2].Value.ToString(), out date))
            {
                return;
            }
            if (!Double.TryParse(dataGridViewExpenses.Rows[e.RowIndex].Cells[3].Value.ToString(), out amount))
            {
                return;
            }
            if ((bool)dataGridViewExpenses.Rows[e.RowIndex].Cells[4].Value)
            {
                approved = 1;
            }
            localInterface.Update("UPDATE expenses SET amount='" + amount + "', date='" + MyUtills.dateToSQL(date) + "',approved='" + approved.ToString() + "',notes='" + dataGridViewExpenses.Rows[e.RowIndex].Cells[0].Value.ToString() + "' WHERE id='" + dataGridViewExpenses.Rows[e.RowIndex].Cells[1].Value.ToString() + "'");
            //showExpenses(Convert.ToInt16(comboBoxSuppliers.SelectedValue));
            //this.BeginInvoke(new MethodInvoker(showExpenses));
        }
Beispiel #6
0
        private void buttonYes_Click(object sender, EventArgs e)
        {
            string app = comboBox1.SelectedIndex.ToString();

            if (ids.Count > 1)
            {
                foreach (string id in ids)
                {
                    if (checkBoxDate.Checked)
                    {
                        if (checkBoxPaiment.Checked)
                        {
                            localInterface.Update("UPDATE expenses SET date='" + MyUtills.dateToSQL(dateTimePicker1.Value) + "',approved='" + app + "' WHERE id=" + id);
                        }
                        else
                        {
                            localInterface.Update("UPDATE expenses SET date='" + MyUtills.dateToSQL(dateTimePicker1.Value) + "' WHERE id=" + id);
                        }
                    }
                    else
                    {
                        if (checkBoxPaiment.Checked)
                        {
                            localInterface.Update("UPDATE expenses SET approved='" + app + "' WHERE id=" + id);
                        }
                    }
                }
            }
            else
            {
                string amount = textBox1.Text.Replace(",", "");
                if (checkBoxDate.Checked)
                {
                    if (checkBoxPaiment.Checked)
                    {
                        localInterface.Update("UPDATE expenses SET date='" + MyUtills.dateToSQL(dateTimePicker1.Value) + "',approved='" + app + "',amount='" + amount + "' WHERE id=" + ids[0]);
                    }
                    else
                    {
                        localInterface.Update("UPDATE expenses SET date='" + MyUtills.dateToSQL(dateTimePicker1.Value) + "',amount='" + amount + "' WHERE id=" + ids[0]);
                    }
                }
                else
                {
                    localInterface.Update("UPDATE expenses SET approved='" + app + "',amount='" + amount + "' WHERE id=" + ids[0]);
                }
            }
            this.Close();
            mainForm.showFinance();
        }
        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();
        }
        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);
        }