コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (isUpdate)
                {
                    DialogResult drResult = MessageBox.Show("Are you sure you want to update the entry?", "Saving Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (drResult == DialogResult.Yes)
                    {
                        string Query           = "Update tbl_CONDO_FloorInfo set FloorName = '" + tbFloorName.Text + "',FloorDescription='" + tbDescription.Text + "',LastUpdateUser="******",LastDateDefined='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where sysID=" + ForUpdate_SysID;
                        bool   isUpdateSuccess = dtrans.InsertData(Query);
                        if (isUpdateSuccess)
                        {
                            MessageBox.Show("Entry successfully updated.", "Update Done", MessageBoxButtons.OK);
                            tbDescription.Text = string.Empty;
                            tbFloorName.Text   = string.Empty;
                            isUpdate           = false;
                        }
                    }
                    button2.Enabled = true;
                    return;
                }

                if (dataGridView1.Rows.Count > 0)
                {
                    DialogResult drResult = MessageBox.Show("Are you sure you want to save the following entries?", "Saving Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (drResult == DialogResult.Yes)
                    {
                        foreach (DataGridViewRow dgrow in dataGridView1.Rows)
                        {
                            Thread.Sleep(100);
                            string Query = "Insert into tbl_CONDO_FloorInfo(FloorName,FloorDescription,userid) values('" + dgrow.Cells["FloorName"].Value.ToString() + "','" + dgrow.Cells["FloorDescription"].Value.ToString() + "',-1)";
                            dgrow.Cells["IsSaved"].Value = dtrans.InsertData(Query);
                        }
                        MessageBox.Show("Data Entry was successfully saved.", "Save Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Error: No Information to Saved.", "Saved Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message.ToString(), "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbYear.Text))
            {
                MessageBox.Show("Error: Invalid Year. Please check your year", "Year Invalid.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbYear.Focus();
                return;
            }
            if (!cv.isInteger(tbYear.Text))
            {
                MessageBox.Show("Error: Invalid Year. Please check your year", "Year Invalid.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbYear.Focus();
                return;
            }
            if (dtStart.Value > dtEnd.Value)
            {
                MessageBox.Show("Error: Date End must be greater than Date Start. Please check your Covered Date", "Year Invalid.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dtStart.Focus();
                return;
            }
            DialogResult drSaveConfirm = MessageBox.Show("Are you sure you want to save this cutoff for month : " + cbMonth.Text + " " + tbYear.Text + "?", "Confirm to Save Cut-off for " + cbMonth.Text + " " + tbYear.Text + "?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (drSaveConfirm == DialogResult.Yes)
            {
                string PrimaryKey  = tbYear.Text + ":" + cbMonth.Text; //(int.Parse(cbMonth.SelectedIndex.ToString()) + 1);
                string QueryInsert = "Insert into tbl_condo_cutoffinfo(PrimaryKey,Year,Month,BillStart,BillEnd,DueDate,isEnabled,CreatedBy)values('" + PrimaryKey + "'," + tbYear.Text + "," + (cbMonth.SelectedIndex + 1) + ",'" + dtStart.Value.ToString("yyyy-MM-dd 00:00:00") + "','" + dtEnd.Value.ToString("yyyy-MM-dd 00:00:00") + "','" + dtDueDate.Value.ToString("yyyy-MM-dd 00:00:00") + "'," + (cbIsEnabled.Checked ? 1 : 0) + "," + UserID + ")";
                dtrans.InsertData(QueryInsert);
                LoadRecords();
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: zenitsuga/Zenitsuga-Systems
        private bool CheckandInjectCode(clsVariableSettings cvs)
        {
            bool result = false;

            try
            {
                string SQLSelectSystemInfo = "select Count(*) from tbl_system_info where isEnabled = 1 and ProgramCode='" + cv.Crypt(programname) + "' and LicenseCode = '" + cvs.LicenseCode + "' and ActivationCode = '" + cvs.ActivationCode + "'";
                cdt = new clsDatabaseTransactions();
                DataTable dtResult    = cdt.SelectData(SQLSelectSystemInfo);
                int       RowAffected = dtResult.Rows.Count;
                RowAffected = RowAffected == 1 ? int.Parse(dtResult.Rows[0][0].ToString()) : 0;
                if (RowAffected == 0)
                {
                    string SQLInsertSystemInfo = "Insert into tbl_system_info(ProgramCode,LicenseCode,ActivationCode)" + " Values ('" + cv.Crypt(programname) + "','" + cvs.LicenseCode + "','" + cvs.ActivationCode + "')";
                    result = cdt.InsertData(SQLInsertSystemInfo);
                }
                else
                {
                    result = true;
                }
            }
            catch
            {
            }
            return(result);
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("Error: Cannot save record. Please check your entry.", "No Record to add", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (isUpdate)
            {
                DialogResult drResult = MessageBox.Show("Are you sure you want to update the entry?", "Saving Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (drResult == DialogResult.Yes)
                {
                    string Query           = "Update tbl_CONDO_UnitInfo set UnitName = '" + tbUnitName.Text + "',UnitDescription='" + tbDescription.Text + "',FloorAssociate=" + cbFloorList.SelectedValue + ",AreaSQM=" + tbArea.Text + ",MonthlyDue=" + tbMonthlyDue.Text + ",IsMonthlyDueComputed=" + (checkBox1.Checked ? 1:0).ToString() + ",LastUpdateUser="******",LastDateDefined='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where sysID=" + ForUpdate_SysID;
                    bool   isUpdateSuccess = dtrans.InsertData(Query);
                    if (isUpdateSuccess)
                    {
                        MessageBox.Show("Entry successfully updated.", "Update Done", MessageBoxButtons.OK);
                        tbDescription.Text = string.Empty;
                        tbUnitName.Text    = string.Empty;
                        isUpdate           = false;
                    }
                }
                button2.Enabled = true;
                return;
            }

            foreach (DataGridViewRow dgrow in dataGridView1.Rows)
            {
                int    FloorID = int.Parse(dtrans.SelectData("Select sysID from tbl_CONDO_FloorInfo where Floorname='" + dgrow.Cells["FloorName"].Value.ToString() + "'").Rows[0][0].ToString());
                string Query   = "Insert into tbl_CONDO_UnitInfo(UnitName,FloorAssociate,Description,AreaSQM,isMontlyDueComputed,MonthlyDue,TotalDue,CreatedBy)Values('" + dgrow.Cells["UnitName"].Value.ToString() + "'," + FloorID + ",'" + dgrow.Cells["UnitDescription"].Value.ToString() + "'," + dgrow.Cells["Size"].Value.ToString() + "," + (dgrow.Cells["MonthlyDueSQM"].Value.ToString() != "0" ? 1:0) + "," + dgrow.Cells["MonthlyDueSQM"].Value.ToString() + "," + dgrow.Cells["TotalDue"].Value.ToString() + "," + UserID + ")";
                if (dtrans.InsertData(Query))
                {
                    MessageBox.Show("Record successfully saved. ", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error: Unable to insert record. Kindly Check your entry", "Saving Record Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
        }
コード例 #5
0
        private bool SaveCustomer()
        {
            bool result = false;

            try
            {
                string PrimaryName = checkBox1.Checked ? tbAlias.Text : tbLastname.Text + "_" + tbFirstname.Text + "_" + tbMiddleName.Text;
                int    isAlias     = checkBox1.Checked ? 1:0;
                string InsertQuery = "insert into tbl_CONDO_CustomerInfo(PrimaryNames,Lastname,FirstName,MiddleName,Alias,UseAlias,ContactNumber,UnitNo,PhotoPath,Notes,CreatedBy) Values ('" + PrimaryName + "','" + tbLastname.Text + "','" + tbFirstname.Text + "','" + tbMiddleName.Text + "','" + tbAlias.Text + "'," + isAlias + ",'" + tbContact.Text + "'," + cbUnit.SelectedValue.ToString() + ",'" + lblPicPath.Text + "','" + tbNotes.Text + "'," + UserID + ")";
                if (dtrans.InsertData(InsertQuery))
                {
                    MessageBox.Show("Customer Information saved.", "Done Saving Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:" + ex.Message.ToString(), "Error Saving Customer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            clsValidation cv = new clsValidation();

            if (dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("Error: No Details to save on this Billing. Please check", "Cannot save Billing Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (cbCutoff.Text == "")
            {
                MessageBox.Show("Error: No Cut-off defined on this Billing. Please check", "Cannot save Billing Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult dr = MessageBox.Show("Are you sure you want to save this Billing Information?", "Confirm Saving Billing Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                string PrimaryKey               = GetLastIDofBilling().ToString("000000000000");
                string checkUnitCutoff          = "SELECT * FROM tbl_condo_billinginfo WHERE cutoffID = " + cv.GetSysID("where PrimaryKey ='" + cbCutoff.Text.ToString() + "'", "tbl_condo_cutoffinfo") + " AND unitno = " + cbUnitNo.SelectedValue;
                bool   isUnitCheckAgainstCutoff = dtrans.SelectData(checkUnitCutoff).Rows.Count > 0 ? true : false;
                if (isUnitCheckAgainstCutoff)
                {
                    MessageBox.Show("Error: Cannot save details for this cut-off. Please check", "Cut-off already exists", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                string BillingInfoQuery = "Insert into tbl_condo_billinginfo(PrimaryKey,CutoffID,CustomerID,UnitNo,TotalAmountDue,PreviousBalanceAsOf,CurrentCharges,CreatedBy)Values('" + PrimaryKey + "'," + cv.isInteger(cv.GetSysID("where PrimaryKey ='" + cbCutoff.Text.ToString() + "'", "tbl_condo_cutoffinfo").ToString()) + "," + lblCustomerID.Text + "," + cbUnitNo.SelectedValue + "," + tbTotalAmount.Text + "," + PreviousBalance + "," + lblCurrenttotal.Text + "," + UserID + ")";
                bool   isErrorFound     = false;
                if (dtrans.InsertData(BillingInfoQuery))
                {
                    if (dataGridView1.Rows.Count > 0)
                    {
                        string GetSySID = cv.GetSysID("where PrimaryKey='" + PrimaryKey + "'", "tbl_condo_billinginfo").ToString();
                        if (GetSySID == "0")
                        {
                            MessageBox.Show("Error: Cannot save billing. Please check", "Error Saving", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            string DeleteDetails = "Delete from tbl_condo_billinginfo where primarykey='" + PrimaryKey + "'";
                            dtrans.InsertData(DeleteDetails);
                            isErrorFound = true;
                            return;
                        }
                        foreach (DataGridViewRow dgrow in dataGridView1.Rows)
                        {
                            string GetManualNotes      = string.IsNullOrEmpty(dgrow.Cells["ManualNotes"].Value.ToString()) ? dgrow.Cells["ManualNotes"].Value.ToString() : string.Empty;
                            string BillingRefID        = GetLastIDofBillingDetails(GetSySID).ToString();
                            string BillingDetailsQuery = "Insert into tbl_condo_billingdetails(PrimaryKey,BillingRefID,BillingDescription,BillingAmount,BillingNotes,CreatedBy)values('" + PrimaryKey + "_" + BillingRefID + "'," + GetSySID + ",'" + dgrow.Cells["Transaction"].Value.ToString() + "'," + dgrow.Cells["Amount"].Value.ToString() + ",'" + GetManualNotes + "'," + UserID + ")";
                            if (!dtrans.InsertData(BillingDetailsQuery))
                            {
                                MessageBox.Show("Error: Cannot save billing details. Please check", "Error Saving", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                string DeleteDetails = "Delete from tbl_condo_billingdetails where billingRefID=" + GetSySID;
                                dtrans.InsertData(DeleteDetails);
                                isErrorFound = true;
                                break;
                            }
                        }
                    }
                    if (!isErrorFound)
                    {
                        MessageBox.Show("Billing information saved", "Done Saving", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    TransactionTable();
                    dataGridView1.DataSource = dtTransactions;
                }
            }
        }