Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            var brak = new OperationForm();

            brak.Show();
            Close();
        }
        public void withdrawAccountTest()
        {
            opForm = new OperationForm("RETRAIT");
            opForm.getSolde("TR0001");
            bool resRet = opForm.withdrawAccount("TR0001", "RETRAIT", 75.5);

            Assert.IsTrue(resRet);
        }
        public void depositAccountTest()
        {
            opForm = new OperationForm("DEPOT");
            opForm.getSolde("TR0001");
            bool resDep = opForm.depositAccount("TR0001", "DEPOT", 300);

            Assert.IsTrue(resDep);
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            var indexW = Convert.ToInt32(comboBox1.SelectedValue.ToString());
            var indext = Convert.ToInt32(comboBox2.SelectedValue.ToString());

            dataBase.operationupd(indexW, indext, textBox2.Text, Convert.ToInt32(textBox2.Text),
                                  Convert.ToInt32(textBox3.Text), _id);
            var brak = new OperationForm();

            brak.Show();
            Close();
        }
Example #5
0
 private void OuvreFormOperation(Operation o, string mode)
 {
     if (TestPasDeCompte())
     {
         OperationForm om = new OperationForm(o, GetCompteCourant(), mode);
         om.ShowDialog();
         if (om.Cont)
         {
             ChargeOperations(GetCompteCourant());
             ChargesIndicateurs(GetCompteCourant());
             ActiveSauvegarde();
         }
         RemplisCb();
     }
 }
Example #6
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var operationForm = new OperationForm(tabControl.SelectedIndex, TypeOfTransaction.Добавление);

            operationForm.ShowDialog(this);

            switch (tabControl.SelectedIndex)
            {
            case 0:
                LoadDataGridViewAccounting();
                break;

            case 1:
                LoadDataGridViewService();
                LoadDataGridViewAccounting();
                break;
            }
        }
Example #7
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object classObject = null;

            switch (tabControl.SelectedIndex)
            {
            case 1:
                try
                {
                    classObject = new Service
                    {
                        Id            = Convert.ToInt32(dataGridViewService.CurrentRow.Cells[0].Value.ToString()),
                        Access        = dataGridViewService.CurrentRow.Cells[5].Value.ToString(),
                        Description   = dataGridViewService.CurrentRow.Cells[4].Value.ToString(),
                        Price         = Convert.ToDouble(dataGridViewService.CurrentRow.Cells[3].Value.ToString()),
                        TypeOfService = (TypeOfService)Enum.Parse(typeof(TypeOfService),
                                                                  dataGridViewService.CurrentRow.Cells[2].Value.ToString()),
                        Name = dataGridViewService.CurrentRow.Cells[1].Value.ToString()
                    };
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("Не выбрана запись для редактирования");
                    return;
                }

                break;

            case 0:
                using (var db = new ModelsContext())
                {
                    try
                    {
                        var currentId =
                            Convert.ToInt32(dataGridViewAccounting.CurrentRow.Cells[0].Value.ToString());

                        var current = db.Accountings.First(x => currentId == x.Id);

                        var currentFullName   = dataGridViewAccounting.CurrentRow.Cells[1].Value.ToString();
                        var currentTypeClient = (TypeClient)Enum.Parse(typeof(TypeClient),
                                                                       dataGridViewAccounting.CurrentRow.Cells[2].Value.ToString());

                        var accountingClient = db.Clients.First(x =>
                                                                x.FullName == currentFullName && x.TypeClient == currentTypeClient);

                        var currentServiceName  = dataGridViewAccounting.CurrentRow.Cells[3].Value.ToString();
                        var currentServicePrice = double.Parse(dataGridViewAccounting.CurrentRow.Cells[4].Value.ToString());

                        var accountingService = db.Services.First(x =>
                                                                  x.Name == currentServiceName && x.Price == currentServicePrice);

                        var payment = db.Payments.First(x => x.Id == current.PaymentId);

                        classObject = new Accounting
                        {
                            Id        = currentId,
                            Client    = accountingClient,
                            ClientId  = accountingClient.Id,
                            Date      = DateTime.Parse(dataGridViewAccounting.CurrentRow.Cells[5].Value.ToString()),
                            Service   = accountingService,
                            ServiceId = accountingService.Id,
                            PaymentId = payment.Id
                        };
                    }
                    catch (NullReferenceException)
                    {
                        MessageBox.Show("Не выбрана запись для редактирования");
                        return;
                    }
                }

                break;
            }


            var operationForm = new OperationForm(tabControl.SelectedIndex, TypeOfTransaction.едактирование, classObject);

            operationForm.ShowDialog(this);

            switch (tabControl.SelectedIndex)
            {
            case 0:
                LoadDataGridViewAccounting();
                break;

            case 1:
                LoadDataGridViewService();
                LoadDataGridViewAccounting();
                break;
            }
        }
Example #8
0
        public bool LaunchProcess(string args, CommandDialog cd, bool bShowProgress = false, string sDestination = "")
        {
            try
            {
                strMessage = string.Empty;
                Process build = new Process();

                Thread thDialog = null;
                if (bShowProgress)
                {
                    if (cd == CommandDialog.Copy)
                    {
                        if (pf == null)
                        {
                            pf = new ProgressForm();
                        }
                        pf.SetProcess(build);
                        pf.SetProgress(string.Empty, 0, sDestination);
                        thDialog = new Thread(() => ThreadProcCopy());
                        thDialog.Start();
                    }
                    else if (cd == CommandDialog.Connect)
                    {
                        if (cf == null)
                        {
                            cf = new ConnectForm();
                        }
                        DeviseAddr addr = new DeviseAddr();
                        if (!string.IsNullOrEmpty(addr.ConnectionType) && addr.ConnectionType.Equals("usb") &&
                            !string.IsNullOrEmpty(addr.UsbDevice))
                        {
                            cf.SetIP(addr.UsbDevice);
                        }
                        else
                        {
                            cf.SetIP(addr.ToString());
                        }

                        thDialog = new Thread(() => ThreadProcConnect());
                        thDialog.Start();
                    }
                    else if (cd == CommandDialog.CreateScreenShot)
                    {
                        if (of == null)
                        {
                            of = new OperationForm(OperationForm.TypeOp.CreateScreenShot);
                        }
                        of.SetOperation("Creating ScreenShot");
                        thDialog = new Thread(() => ThreadProcOperation());
                        thDialog.Start();
                    }
                    else if (cd == CommandDialog.Install)
                    {
                        if (of == null)
                        {
                            of = new OperationForm(OperationForm.TypeOp.Install);
                        }
                        of.SetOperation("Install " + args.Substring(args.LastIndexOf("\\") + 1).TrimEnd('\"'));
                        thDialog = new Thread(() => ThreadProcOperation());
                        thDialog.Start();
                    }
                    else if (cd == CommandDialog.Delete)
                    {
                        if (of == null)
                        {
                            of = new OperationForm(OperationForm.TypeOp.Delete);
                        }
                        of.SetOperation("Deleting");
                        thDialog = new Thread(() => ThreadProcOperation());
                        thDialog.Start();
                    }
                }

                build.StartInfo.WorkingDirectory = Path.GetDirectoryName(FindADB());

                if (string.IsNullOrEmpty(build.StartInfo.WorkingDirectory))
                {
                    if (bShowProgress && pf != null)
                    {
                        pf.SetProgress(string.Empty, 0);
                        pf.InternalCloseDialog();
                        pf = null;
                    }
                    if (bShowProgress && cf != null)
                    {
                        cf.InternalCloseDialog();
                        cf = null;
                    }
                    if (bShowProgress && of != null)
                    {
                        of.InternalCloseDialog();
                        of = null;
                    }
                    strMessage = "Can not find adb.exe";
                    return(false);
                }

                build.StartInfo.FileName  = FindADB();
                build.StartInfo.Arguments = args;

                build.StartInfo.UseShellExecute        = false;
                build.StartInfo.RedirectStandardOutput = true;
                build.StartInfo.RedirectStandardError  = true;
                build.StartInfo.CreateNoWindow         = true;
                build.ErrorDataReceived  += build_ErrorDataReceived;
                build.OutputDataReceived += build_ErrorDataReceived;
                build.EnableRaisingEvents = true;
                build.Start();
                build.BeginOutputReadLine();
                build.BeginErrorReadLine();
                build.WaitForExit();

                if (bShowProgress)
                {
                    if (cd == CommandDialog.Copy)
                    {
                        if (build.ExitCode < 0)
                        {
                            if (!string.IsNullOrEmpty(sDestination))
                            {
                                if (File.Exists(sDestination))
                                {
                                    File.Delete(sDestination);
                                }
                                else if (Directory.Exists(sDestination))
                                {
                                    //Directory.Delete(sDestination, true);
                                }
                            }
                        }

                        if (pf != null)
                        {
                            pf.SetProgress(string.Empty, 0);
                            pf.InternalCloseDialog();
                            pf = null;
                        }
                    }
                    else if (cd == CommandDialog.Connect)
                    {
                        cf.InternalCloseDialog();
                        cf = null;
                    }
                    else if (cd == CommandDialog.CreateScreenShot || cd == CommandDialog.Delete || cd == CommandDialog.Install)
                    {
                        of.InternalCloseDialog();
                        of = null;
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                if (bShowProgress)
                {
                    if (cd == CommandDialog.Copy)
                    {
                        if (pf != null)
                        {
                            pf.SetProgress(string.Empty, 0);
                            pf.InternalCloseDialog();
                            pf = null;
                        }
                    }
                    else if (cd == CommandDialog.Connect)
                    {
                        cf.InternalCloseDialog();
                        cf = null;
                    }
                    else if (cd == CommandDialog.CreateScreenShot || cd == CommandDialog.Delete)
                    {
                        of.InternalCloseDialog();
                        of = null;
                    }
                }

                strMessage = e.Message;
                return(false);
            }
        }
Example #9
0
        public bool LaunchProcess(List <FileOperation> lstItems, CommandDialog cd, bool bShowProgress = false)
        {
            string sAdb = FindADB();

            if (string.IsNullOrEmpty(sAdb))
            {
                strMessage = "Can not find adb.exe";
                return(false);
            }

            Thread thCopy = null;

            if (bShowProgress)
            {
                if (cd == CommandDialog.Copy)
                {
                    if (pf == null)
                    {
                        pf       = new ProgressForm();
                        pf.Files = lstItems;
                    }

                    thCopy = new Thread(() => ThreadProcCopy());
                    thCopy.Start();
                }
                if (cd == CommandDialog.Delete)
                {
                    if (of == null)
                    {
                        of = new OperationForm(OperationForm.TypeOp.Delete);
                        of.SetOperation("Deleting");
                    }

                    thCopy = new Thread(() => ThreadProcOperation());
                    thCopy.Start();
                }
            }

            int  iFile = 0;
            bool bRet  = true;

            foreach (FileOperation fileOperation in lstItems)
            {
                Process build = new Process();

                if (cd == CommandDialog.Copy)
                {
                    if (bShowProgress && pf != null)
                    {
                        pf.SetProgressVisible(false);
                        pf.CurrentPosition = iFile;
                        pf.SetProcess(build, fileOperation.IsFolder ? "1" : "0");
                        pf.SetProgress(fileOperation.Source, 0, fileOperation.Destination);
                    }
                }

                build.StartInfo.WorkingDirectory = Path.GetDirectoryName(sAdb);
                build.StartInfo.FileName         = sAdb;
                build.StartInfo.Arguments        = fileOperation.Command;

                build.StartInfo.UseShellExecute        = false;
                build.StartInfo.RedirectStandardOutput = true;
                build.StartInfo.RedirectStandardError  = true;
                build.StartInfo.CreateNoWindow         = true;
                build.ErrorDataReceived  += build_ErrorDataReceived;
                build.OutputDataReceived += build_ErrorDataReceived;
                build.EnableRaisingEvents = true;
                build.Start();
                build.BeginOutputReadLine();
                build.BeginErrorReadLine();
                build.WaitForExit();

                if (bShowProgress)
                {
                    if (cd == CommandDialog.Copy)
                    {
                        if (build.ExitCode < 0)
                        {
                            if (!string.IsNullOrEmpty(fileOperation.Destination))
                            {
                                if (File.Exists(fileOperation.Destination))
                                {
                                    File.Delete(fileOperation.Destination);
                                }
                                else if (Directory.Exists(fileOperation.Destination))
                                {
                                    //Directory.Delete(sDestination, true);
                                }
                            }

                            if (pf != null)
                            {
                                pf.SetProgress(string.Empty, 0);
                                pf.InternalCloseDialog();
                                pf = null;
                            }

                            break;
                        }
                        else
                        {
                            if (pf != null)
                            {
                                pf.SetProgress(string.Empty, 0);
                            }
                        }
                    }
                }

                if (strMessage != null && (strMessage.Contains("adb: error:") || strMessage.Contains("Read-only file system") || strMessage.Contains(": Permission denied")))
                {
                    bRet = false;
                    break;
                }

                iFile++;
            }

            if (bShowProgress)
            {
                if (cd == CommandDialog.Copy)
                {
                    if (pf != null)
                    {
                        pf.SetProgress(string.Empty, 0);
                        pf.InternalCloseDialog();
                        pf = null;
                    }
                }
                if (cd == CommandDialog.Delete)
                {
                    if (of != null)
                    {
                        of.InternalCloseDialog();
                        of = null;
                    }
                }
            }

            return(bRet);
        }