Example #1
0
        private void UpdateDatacompany(DataCompany DC)
        {
            using (SqlConnection con = ConexionSQL.Cadenaconexion("ATX_POS"))
            {
                con.Open();
                SqlCommand command = new SqlCommand();
                command.Parameters.Clear();
                command.Connection = con;

                command.CommandText = ("Select TOP 1 [NameCompany] from Company where [no] <> 0");
                string Exist = command.ExecuteScalar().ToString();
                if (Exist == null)
                {
                    command.Parameters.Clear();
                    command.CommandText = ("Insert into Company ([NameCompany],[Location],[RFC],[PCode],[City],[StateMex],[Email],[Phone]) values(@NameCompany,@Location,@RFC,@PCode,@City,@StateMex,@Email,@Phone)");
                    command.Parameters.AddWithValue("@NameCompany", DC.Name.ToString());
                    command.Parameters.AddWithValue("@Location", (DC.Address.ToString() + ", " + DC.Address_2.ToString()));
                    command.Parameters.AddWithValue("@RFC", DC.VAT_Registration_No.ToString());
                    command.Parameters.AddWithValue("@PCode", DC.Post_Code.ToString());
                    command.Parameters.AddWithValue("@City", DC.City.ToString());
                    command.Parameters.AddWithValue("@StateMex", DC.County.ToString());
                    command.Parameters.AddWithValue("@Email", DC.E_Mail.ToString());
                    command.Parameters.AddWithValue("@Phone", DC.Phone_No.ToString());
                    command.ExecuteScalar();
                    MessageBox.Show("Datos Actualizados, La aplicación se reiniciara para tomar los cambios", "Actualización Correcta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (Exist != null)
                {
                    DialogResult result;
                    result = MessageBox.Show("Se modificaran los datos de la empresa en la base local"
                                             + System.Environment.NewLine
                                             + "¿Desea continuar?", "Registro Duplicado", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {
                        command.Parameters.Clear();
                        command.CommandText = ("UPDATE Company set [NameCompany] = @NameCompany,[Location] = @Location,[RFC] = @RFC,[PCode] = @PCode,[City] = @City,[StateMex] = @StateMex,[Email] = @Email,[Phone] = @Phone where [no] > 0");
                        command.Parameters.AddWithValue("@NameCompany", DC.Name.ToString());
                        command.Parameters.AddWithValue("@Location", (DC.Address.ToString() + ", " + DC.Address_2.ToString()));
                        command.Parameters.AddWithValue("@RFC", DC.VAT_Registration_No.ToString());
                        command.Parameters.AddWithValue("@PCode", DC.Post_Code.ToString());
                        command.Parameters.AddWithValue("@City", DC.City.ToString());
                        command.Parameters.AddWithValue("@StateMex", DC.County.ToString());
                        command.Parameters.AddWithValue("@Email", DC.E_Mail.ToString());
                        command.Parameters.AddWithValue("@Phone", DC.Phone_No.ToString());
                        try
                        {
                            command.ExecuteNonQuery();
                            MessageBox.Show("Datos Actualizados, La aplicación se reiniciara para tomar los cambios", "Actualización Correcta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            updatecorrectcompany = true;
                        }
                        catch (SqlException sqle)
                        {
                            MessageBox.Show(sqle.Message);
                        }
                    }
                }
                con.Close();
            }
        }
Example #2
0
        public static void SetupInfoFile(ABNData data)
        {
            CreateDirectory(FormatABN(data.ABN));

            string      path        = GetDirectory(data.ABN);
            string      x           = JsonConvert.SerializeObject(data);
            DataCompany dataCompany = new DataCompany();

            dataCompany.ABN          = FormatABN(data.ABN);
            dataCompany.CompanyName  = data.CompanyName;
            dataCompany.OfficeNumber = data.Phone;
            dataCompany.Email        = data.Email;

            StreamWriter writer = File.CreateText(path + "/CompanyInfo.info");

            writer.Write(JsonConvert.SerializeObject(dataCompany));
            writer.Flush();
            writer.Close();
        }