Exemplo n.º 1
0
 protected void rptEquipment_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("delete"))
     {
         LinkButton           btnDelete = (LinkButton)e.CommandSource;
         TestEquipmentService rptbso    = new TestEquipmentService();
         if (rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)) > 0)
         {
             BindEquipment();
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Không xóa được. Vui lòng thử lại.');", true);
         }
     }
     else if (e.CommandName.Equals("edit"))
     {
         LinkButton           btnEdit = (LinkButton)e.CommandSource;
         TestEquipment        equip   = new TestEquipment();
         TestEquipmentService rptbso  = new TestEquipmentService();
         equip             = rptbso.FindByKey(int.Parse(((LinkButton)e.CommandSource).CommandArgument));
         hdnDetailId.Value = equip.Id.ToString();
         if (equip.Quantity > 0)
         {
             txtQuantity.Text = equip.Quantity.ToString();
         }
         //txtMeasurement.Text = equip.Measurement;
         txtEquipmentName.Text = equip.DeviceName;
         txtMadeIn.Text        = equip.MadeIn;
         ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogEquipment();", true);
     }
 }
Exemplo n.º 2
0
    void BindEquipment()
    {
        DataTable dt = new DataTable();

        dt = new TestEquipmentService().GetList(ReportId);
        rptEquipment.DataSource = dt;
        rptEquipment.DataBind();
    }
Exemplo n.º 3
0
    protected void btnSaveEquipment_Click(object sender, EventArgs e)
    {
        TestEquipmentService testEquipmentService = new TestEquipmentService();
        TestEquipment        testEquipment        = new TestEquipment();

        testEquipment.AuditReportId = ReportId;
        testEquipment.DeviceName    = txtEquipmentName.Text.Trim();
        testEquipment.Quantity      = Convert.ToInt32(txtQuantity.Text.Trim());
        //testEquipment.Measurement = txtMeasurement.Text.Trim();
        testEquipment.MadeIn   = txtMadeIn.Text.Trim();
        testEquipment.SerialNo = txtSerialNumber.Text.Trim();

        if (hdnDetailId.Value != "" && Convert.ToInt32(hdnDetailId.Value) > 0)
        {
            testEquipment.Id = Convert.ToInt32(hdnDetailId.Value);
            if (testEquipmentService.Update(testEquipment) != null)
            {
                BindEquipment();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogEquipment();", true);
                ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công. Vui lòng thử lại!');", true);
            }
        }
        else
        {
            int i = testEquipmentService.Insert(testEquipment);
            if (i > 0)
            {
                BindEquipment();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogAddEquipment();", true);
                ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Thêm mới kê hoạch không thành công. Vui lòng thử lại!');", true);
            }
        }
    }