コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (RadDropDownWorksheets.SelectedValue.ToSafeString() == "")
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "اطلاعاتی برای ذخیره کردن یافت نشد";
                return;
            }

            var selectedWSInsertDateTime = (DateTime) new WorksheetRepository().GetById(RadDropDownWorksheets.SelectedValue.ToSafeInt()).InsertDateTime;

            var dt = (DataTable)Session["Result"];

            if (dt == null)
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "اطلاعاتی برای ذخیره کردن یافت نشد";
                return;
            }

            var uow = new UnitOfWork();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var wlDateTime = new DateTime(selectedWSInsertDateTime.Date.Year, selectedWSInsertDateTime.Date.Month, selectedWSInsertDateTime.Date.Day, dt.Rows[i].Field <int>("Hour").ToSafeInt(), dt.Rows[i].Field <int>("Min").ToSafeInt(), 0);

                var newWorkline = new Repository.Entity.Domain.WorkLine()
                {
                    OperatorId     = dt.Rows[i].Field <int>("OperatorId"),
                    ProcessId      = dt.Rows[i].Field <int>("ProcessId"),
                    InsertDateTime = wlDateTime,
                    WorksheetId    = RadDropDownWorksheets.SelectedValue.ToSafeInt(),
                    Manual         = true
                };

                uow.WorkLines.Create(newWorkline);
            }

            var result = uow.SaveChanges();

            if (result.IsSuccess)
            {
                lblMessage.Visible = false;

                Session["PostProcessMessage"] = new PostProcessMessage()
                {
                    Message     = "عملیات با موفقیت انجام شد",
                    MessageType = MessageType.Success
                };
                Response.Redirect("ManualWorkLineInput.aspx");
            }
            else
            {
                Session["PostProcessMessage"] = null;
                lblMessage.Visible            = true;
                lblMessage.Text = result.ResultMessage;
            }
        }
コード例 #2
0
        protected void btnAccept_Click(object sender, EventArgs e)
        {
            var data = ((ConfirmData)Session["ConfirmData"]);
            var id   = data.Id;

            var table = data.Table;

            try
            {
                Repository.DAL.ActionResult result = null;

                if (string.IsNullOrEmpty(data.RawCommand))
                {
                    result = new UnitOfWork().ExecCommand("Delete from " + table + " Where id = @Id",
                                                          new SqlParameter("@Id", id));
                }
                else
                {
                    result = new UnitOfWork().ExecCommand(data.RawCommand);
                }

                if (!result.IsSuccess)
                {
                    throw new LocalException("Error in Deleting from " + table + " with id " + id, "خطا در حذف");
                }
                ((Main)Page.Master).SetGeneralMessage("عملیات با موفقیت انجام شد", MessageType.Success);


                Session["PostProcessMessage"] = new PostProcessMessage()
                {
                    Message     = "عملیات با موفقیت انجام شد",
                    MessageType = MessageType.Success
                };

                if (data.RedirectAdr.ToSafeString() != "")
                {
                    if (data.RedirectAdr.ToLower().Contains(".aspx"))
                    {
                        Response.Redirect(data.RedirectAdr);
                    }
                    else
                    {
                        Response.RedirectToRoute(data.RedirectAdr, data.RedirectRouteValueDictionary);
                    }
                }
            }
            catch (LocalException exception)
            {
                ((Main)Page.Master).SetGeneralMessage(exception.ResultMessage, MessageType.Error);
            }
            catch (Exception ex)
            {
                ((Main)Page.Master).SetGeneralMessage("به علت بروز مشکل درخواست شما انجام نشد-" + ex.Message, MessageType.Error);
            }
        }
コード例 #3
0
        protected void gridList_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            var routeValues = new RouteValueDictionary();
            routeValues.Add("Id", e.CommandArgument);

            if (e.CommandName == "Edit")
            {
                Response.RedirectToRoute("Process", routeValues);
                Response.End();
            }
            else if (e.CommandName == "Delete")
            {
                if (e.CommandArgument.ToSafeInt() == 99 || e.CommandArgument.ToSafeInt() == 999)
                {
                    Session["PostProcessMessage"] = new PostProcessMessage()
                    {
                        Message = "این فرآیند سیستمی است و قابل حذف نیست",
                        MessageType = MessageType.Error
                    };

                    Response.RedirectToRoute("ProcessList");
                }
                else
                {
                    var data = new ConfirmData();

                    data.Command = "Delete";
                    data.Id = e.CommandArgument.ToSafeInt();
                    data.Msg = "آیا از حذف اطمینان دارید؟";
                    data.Table = "Processes";
                    data.RedirectAdr = "ProcessList";

                    Session["ConfirmData"] = data;
                    Response.RedirectToRoute("Confirmation");
                    Response.End();
                }
               
            }
        }