コード例 #1
0
        protected void GridViewResult_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName.ToLower())
                {
                case "removeemployeedevice":
                {
                    EmployeeDevice.DeleteEmployeeDeviceByEmployeeDeviceId(Convert.ToInt32(e.CommandArgument));
                    BindGridviewResult();
                    break;
                }
                }
            }

            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
        }
コード例 #2
0
 protected void GridViewResult_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         switch (e.CommandName.ToLower())
         {
         case "removeemployeedevice":
         {
             EmployeeDevice.DeleteEmployeeDeviceByDeviceId(Convert.ToInt32(e.CommandArgument));
             GridViewResult.DataSource = Device.GetDeviceListByFilter("%" + "%" + "%", Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId);
             GridViewResult.DataBind();
             break;
         }
         }
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         //LabelError.Text = "";
         //for (int i = 0; i < sqlEx.Errors.Count; i++)
         //{
         //    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
         //}
         //PanelError.Visible = true;
     }
 }
コード例 #3
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                LabelError.Text    = "";
                PanelError.Visible = false;

                DateTime dateOfDeviceReceived;
                bool     isDate = DateTime.TryParse(TextBoxDateReceived.Text, out dateOfDeviceReceived);

                if (!isDate)
                {
                    LabelError.Text   += "Device Received Date is required.<br />";
                    PanelError.Visible = true;
                    return;
                }

                //EmployeeVehicle employeeVehicle = EmployeeVehicle.GetEmployeeVehicleByEmployeeIdVehicleId(this.employeeId, Convert.ToInt32(DropDownListVehicle.SelectedValue));

                EmployeeDevice employeeDevice = new EmployeeDevice();
                employeeDevice.EmployeeDeviceId = this.employeeDeviceId;//Convert.ToInt32(ViewState["employeeDeviceId"]);
                employeeDevice.DeviceId         = Convert.ToInt32(DropDownListDevice.SelectedValue);
                employeeDevice.EmployeeId       = this.employeeId;
                employeeDevice.DateReceived     = Convert.ToDateTime(TextBoxDateReceived.Text);
                employeeDevice.ModifiedUser     = this.Master.LoggedOnAccount;

                try
                {
                    employeeDevice.Save();
                    this.employeeDeviceId = employeeDevice.EmployeeDeviceId;

                    Button clickedButton = (Button)sender;
                    switch (clickedButton.ID)
                    {
                    case "ButtonSave":
                        Response.Redirect(String.Format("EmployeeEdit.aspx?employeeId={0}", this.employeeId));
                        break;

                    case "ButtonSaveNew":
                        Response.Redirect(String.Format("EmployeeDeviceEdit.aspx?employeeId={0}", this.employeeId));
                        break;
                    }
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                    PanelError.Visible = true;
                }
            }
        }
コード例 #4
0
        public async Task <bool> CheckDevice(int empId, string deviceId)
        {
            EmployeeDevice device = await _uow.DeviceRepository.GetFirst(filter : el => el.DeviceId == deviceId && el.EmpId == empId);

            if (device == null)
            {
                EmployeeDevice newDevice = new EmployeeDevice()
                {
                    EmpId    = empId,
                    DeviceId = deviceId
                };
                _uow.DeviceRepository.Add(newDevice);
            }
            else
            {
                device.DeviceId = deviceId;
                _uow.DeviceRepository.Update(device);
            }
            return(await _uow.SaveAsync() > 0);
        }
コード例 #5
0
        private void BindEmployeeDevice()
        {
            try
            {
                EmployeeDevice employeeDevice = EmployeeDevice.GetEmployeeDeviceByEmployeeDeviceId(this.employeeDeviceId);
                DropDownListDevice.Items.FindByValue(employeeDevice.DeviceId.ToString()).Selected = true;
                TextBoxDateReceived.Text = employeeDevice.DateReceived.ToString("yyyy/MM/dd");;

                BindGridviewResult();
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
            catch (Exception exception)
            {
                LabelError.Text   += (exception.Message + "<br />");
                PanelError.Visible = true;
            }
        }
コード例 #6
0
 private void BindGridviewResult()
 {
     GridViewResult.DataSource = EmployeeDevice.GetEmployeeDeviceList(this.employeeId);
     GridViewResult.DataBind();
 }