示例#1
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper;

            args.ValidateArguments();

            ProgramSettings.SourceFilePath      = args[1];
            ProgramSettings.DestinationFilePath = args[2];

            Enum.TryParse <ProgramMode>(args[0], true, out var mode);
            CompressorService service;

            switch (mode)
            {
            case ProgramMode.Compress:
                Console.WriteLine($"{ProgramMode.Compress} started");
                service = new CompressorService(new Zipper(),
                                                new FileReader(ProgramSettings.SourceFilePath),
                                                new ZipStreamWriter(ProgramSettings.DestinationFilePath));
                break;

            case ProgramMode.Decompress:
                Console.WriteLine($"{ProgramMode.Decompress} started");
                service = new CompressorService(new Unzipper(),
                                                new CompressedFileReader(ProgramSettings.SourceFilePath),
                                                new FileStreamWriter(ProgramSettings.DestinationFilePath));
                break;

            default:
                throw new Exception($"Неожиданный режим: {mode}");
            }

            service.Start();
        }
示例#2
0
    private void BindCompressor()
    {
        CompressorService productConsumeService = new CompressorService();
        DataTable         tbl = new DataTable();

        tbl = productConsumeService.GetCompressorByReport(ReportId);
        rptCompressor.DataSource = tbl;
        rptCompressor.DataBind();
    }
示例#3
0
    public void btnSaveC_Click(object sender, EventArgs e)
    {
        CompressorService productCapacityService = new CompressorService();
        Compressor        productCapacity        = new Compressor();

        if (txtPressureC.Text.Trim() != "")
        {
            productCapacity.Pressure = Convert.ToDecimal(txtPressureC.Text.Trim());
        }
        if (txtPressureLVC.Text.Trim() != "")
        {
            productCapacity.PressureLV = Convert.ToDecimal(txtPressureLVC.Text.Trim());
        }
        if (txtQuantityC.Text.Trim() != "")
        {
            productCapacity.Quantity = Convert.ToInt32(txtQuantityC.Text.Trim());
        }
        if (txtHoursC.Text.Trim() != "")
        {
            productCapacity.OperationHours = Convert.ToInt32(txtHoursC.Text.Trim());
        }
        if (txtCapacityC.Text.Trim() != "")
        {
            productCapacity.Capacity = Convert.ToDecimal(txtCapacityC.Text.Trim());
        }
        productCapacity.AuditReportId = ReportId;


        int i = 0;

        if (hdnId.Value != "" && Convert.ToInt32(hdnId.Value) > 0)
        {
            productCapacity.Id = Convert.ToInt32(hdnId.Value);
            productCapacity    = productCapacityService.Update(productCapacity);
            if (productCapacity != null)
            {
                i = 1;
            }
        }
        else
        {
            i = productCapacityService.Insert(productCapacity);
        }
        if (i <= 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công. Vui lòng thử lại!');", true);
            ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogCompressor(" + hdnId.Value + ");", true);
        }
        else
        {
            BindCompressor();
        }
    }
示例#4
0
 protected void rptCompressor_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("delete"))
     {
         CompressorService productCapacityService = new CompressorService();
         long i = productCapacityService.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument));
         if (i > 0)
         {
             BindCompressor();
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "alert('Xóa không thành không. Vui lòng thử lại');", true);
         }
     }
     else if (e.CommandName.Equals("edit"))
     {
         Compressor        productCapacity        = new Compressor();
         CompressorService productCapacityService = new CompressorService();
         int ProductCapacityId = int.Parse(((LinkButton)e.CommandSource).CommandArgument);
         productCapacity = productCapacityService.FindByKey(ProductCapacityId);
         if (productCapacity != null)
         {
             txtDeviceNameC.Text = productCapacity.CompressorName;
             if (productCapacity.Quantity > 0)
             {
                 txtQuantityC.Text = productCapacity.Quantity.ToString();
             }
             if (productCapacity.Capacity > 0)
             {
                 txtCapacityC.Text = productCapacity.Capacity.ToString();
             }
             if (productCapacity.Pressure > 0)
             {
                 txtPressureC.Text = productCapacity.Pressure.ToString();
             }
             if (productCapacity.PressureLV > 0)
             {
                 txtPressureLVC.Text = productCapacity.PressureLV.ToString();
             }
             if (productCapacity.OperationHours > 0)
             {
                 txtHoursC.Text = productCapacity.OperationHours.ToString();
             }
         }
         hdnId.Value = ProductCapacityId.ToString();
         ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogCompressor(" + hdnId.Value + ");", true);
     }
 }