Example #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LandingScreen()); // initializes the Home screen

            if (OpenDetailFormOnClose)
            {
                Application.Run(new Home(LandingScreen.GetSchemaName(LandingScreen.newschemaName)));
            }
        }
Example #2
0
        private void getCCToCoSD_DoWork(object sender, DoWorkEventArgs e)
        {
            backgroundWorker.ReportProgress(1);
            count = 0;
            string schema = LandingScreen.GetSchemaName(LandingScreen.newschemaName);
            //string connectionString = ConfigurationManager.ConnectionStrings["Master_CoSD_Tool.Properties.Settings.MasterCoSDConnectionString"].ConnectionString;
            string connectionString = ConfigurationManager.ConnectionStrings["CoSD_Tool.Properties.Settings.AP_ToolCoSDConnectionString"].ConnectionString;
            string commandText      = " ";


            if (schema.Equals("AnimalProductsCoSD.CoSD."))
            {
                commandText = schema + "sp_cc_to_ap";
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    SqlCommand cmd = new SqlCommand(commandText, conn);
                    //Indefinite timeout
                    cmd.CommandTimeout = 0;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    var returnParam = new SqlParameter
                    {
                        ParameterName = "@Return",
                        Direction     = ParameterDirection.ReturnValue,
                    };
                    cmd.Parameters.Add(returnParam);

                    try
                    {
                        conn.Open();
                        count = cmd.ExecuteNonQuery();
                        int retunvalue = (int)cmd.Parameters["@Return"].Value;
                        if (count > 0 && retunvalue == 1)
                        {
                            saveAction("CC to AP. " + count + " Records processed Successfully");
                            backgroundWorker.ReportProgress(2);
                        }
                        else
                        {
                            backgroundWorker.ReportProgress(0);
                            MessageBox.Show("No Records processed.");
                        }
                    }

                    catch (Exception ex)
                    {
                        backgroundWorker.ReportProgress(0);
                        MessageBox.Show("Data processing unsuccessful, please contact technical team.");
                        saveAction("CC to AP: " + ex.Message);
                    }

                    finally
                    {
                        conn.Close();
                    }
                }
            }

            if (schema.Equals("VegetablesCoSD.CoSD."))
            {
                commandText = schema + "sp_cc_to_veg";
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    SqlCommand cmd = new SqlCommand(commandText, conn);
                    //Indefinite timeout
                    cmd.CommandTimeout = 0;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    var returnParam = new SqlParameter
                    {
                        ParameterName = "@Return",
                        Direction     = ParameterDirection.ReturnValue,
                    };
                    cmd.Parameters.Add(returnParam);

                    try
                    {
                        conn.Open();
                        count = cmd.ExecuteNonQuery();
                        int retunvalue = (int)cmd.Parameters["@Return"].Value;
                        if (count > 0 && retunvalue == 1)
                        {
                            saveAction("CC to AP. " + count + " Records processed Successfully");
                            backgroundWorker.ReportProgress(2);
                        }
                        else
                        {
                            backgroundWorker.ReportProgress(0);
                            MessageBox.Show("No Records processed.");
                        }
                    }

                    catch (Exception ex)
                    {
                        backgroundWorker.ReportProgress(0);
                        Console.WriteLine(ex.Message);
                        MessageBox.Show("Data processing unsuccessful, please contact technical team.");
                        saveAction("CC to Veg: " + ex.Message);
                    }

                    finally
                    {
                        conn.Close();
                    }
                }
            }

            if (schema.Equals("FruitsCoSD.CoSD."))
            {
                MessageBox.Show("The procedure for this Commodity does not exist");
            }
        }
 private void button_addconversion_Click(object sender, EventArgs e)
 {
     groupBox_addconversion.Visible = true;
     fillcommodityComboboxForAdd(LandingScreen.GetGroupId(LandingScreen.newschemaName));
 }