Exemple #1
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (ButtonSave.Text.Equals("Update"))
            {
                ButtonUpdate_Click();
            }

            else
            {
                if (IsValidManualEntry(false))
                {
                    LabelMessage.Text = "";

                    String barcode       = TextBoxBarcode.Text;
                    String description   = TextBoxDescription.Text.Replace("'", "''");
                    String amount        = TextBoxAmount.Text.Replace(",", "");
                    String costGlCode    = TextBoxGlCode.Text;
                    String vendorId      = TextBoxVendorID.Text;
                    String vendorName    = TextBoxVendorName.Text.Replace("'", "''");
                    String invoiceNumber = TextBoxInvoiceNumber.Text;
                    String invoiceDate   = TextBoxDate.Text;
                    String department    = bearCode.GetDepartmentCodeFromGLCode(costGlCode, VariablesCashManager.ERROR_LOG_FILE_NAME);
                    String company       = RadioButtonListLocation.SelectedValue;
                    String currency      = RadioButtonListCurrency.SelectedValue;
                    String office        = DropDownListOffice.SelectedValue;

                    SqlConnection con       = new SqlConnection(ConfigurationManager.ConnectionStrings["eliteConnectionString"].ConnectionString);
                    String        sqlInsert = "";
                    try
                    {
                        sqlInsert = " INSERT INTO dbo.BMcBEARCashFlowManagerManualEntries "
                                    + " (barcode, enteredBy, description, amount, costGlCode, vendorId, vendorName, invoiceNumber "
                                    + " ,invoiceDate, department, company, office, currency, modifiedTime) "
                                    + " VALUES ( "
                                    + barcode
                                    + ", '" + Page.User.Identity.Name.ToString().Substring(8) + "' "
                                    + ", '" + description + "' "
                                    + ", " + amount
                                    + ", '" + costGlCode + "' "
                                    + ", '" + vendorId + "' "
                                    + ", '" + vendorName + "' "
                                    + ", '" + invoiceNumber + "' "
                                    + ", '" + invoiceDate + "' "
                                    + ", '" + department + "' "
                                    + ", '" + company + "' "
                                    + ", '" + office + "' "
                                    + ", '" + currency + "' "
                                    + ", '" + DateTime.Now + "' "
                                    + " ) ";

                        con.Open();

                        SqlCommand command = con.CreateCommand();
                        command.CommandText = sqlInsert;
                        command.CommandType = CommandType.Text;

                        command.ExecuteNonQuery();

                        if (Session["barcode"] != null)
                        {
                            LabelMessage.Text  = "Barcode " + Session["barcode"].ToString() + " Successfully Added.";
                            Session["barcode"] = null;
                        }
                        resetForm();
                    }
                    catch (SqlException sqle)
                    {
                        Logger.QuickLog(VariablesCashManager.ERROR_LOG_FILE_NAME, sqle.Message, "ButtonSave_Click()", sqlInsert);
                    }
                    finally
                    {
                        if (con != null)
                        {
                            con.Close();
                        }
                    }
                }
            }
        }