Esempio n. 1
0
        protected void rdFryersGrid_OnItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "delete":
                HiddenField hdnDeepFryerId = e.Item.FindControl("hdnDeepFryerId") as HiddenField;

                if (hdnDeepFryerId != null)
                {
                    DeepFryerEntity deepFryer = new DeepFryerEntity(Convert.ToInt32(hdnDeepFryerId.Value));
                    deepFryer.IsActive = false;
                    deepFryer.Save();

                    ChangeLogEntity cle = new ChangeLogEntity();
                    cle.UserId       = sm.AuthenticatedUser.UserId;
                    cle.ChangeDate   = DateTime.Now;
                    cle.ChangeTypeId = (int)ChangeTypeEntity.ChangeTypes.FryerRemoved;
                    DeepFryerChangeLogEntity dfcle = new DeepFryerChangeLogEntity();
                    dfcle.DeepFryerId = deepFryer.DeepFryerId;
                    dfcle.ChangeLog   = cle;
                    dfcle.Save(true);
                }
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        protected void btnSaveFryers_Click(object sender, EventArgs e)
        {
            foreach (GridDataItem item in rdFryersGrid.Items)
            {
                TextBox     txtDeepFryerName          = item.FindControl("txtDeepFryerName") as TextBox;
                TextBox     txtDeepFryerDescription   = item.FindControl("txtDeepFryerDescription") as TextBox;
                TextBox     txtDeepFryerSizeInGallons = item.FindControl("txtDeepFryerSizeInGallons") as TextBox;
                HiddenField hdnDeepFryerId            = item.FindControl("hdnDeepFryerId") as HiddenField;
                HiddenField hdnOrigSize = item.FindControl("hdnOrigSize") as HiddenField;

                if (hdnDeepFryerId != null)
                {
                    DeepFryerEntity deepFryer = new DeepFryerEntity(Convert.ToInt32(hdnDeepFryerId.Value));
                    deepFryer.Name        = txtDeepFryerName.Text.Trim();
                    deepFryer.Description = txtDeepFryerDescription.Text.Trim();
                    if (deepFryer.SizeInGallons != null)
                    {
                        try
                        {
                            double orgSize = Convert.ToDouble(hdnOrigSize.Value);
                            double newSize = Convert.ToDouble(txtDeepFryerSizeInGallons.Text.Trim());

                            if (orgSize != newSize)
                            {
                                ChangeLogEntity cle = new ChangeLogEntity();
                                cle.UserId       = sm.AuthenticatedUser.UserId;
                                cle.ChangeDate   = DateTime.Now;
                                cle.ChangeTypeId = newSize > orgSize ? (int)ChangeTypeEntity.ChangeTypes.FryerSizeIncrease : (int)ChangeTypeEntity.ChangeTypes.FryerSizeDecrease;
                                DeepFryerChangeLogEntity dfcle = new DeepFryerChangeLogEntity();
                                dfcle.DeepFryerId = deepFryer.DeepFryerId;
                                dfcle.ChangeLog   = cle;
                                dfcle.Save(true);
                            }
                        }
                        catch { }
                    }


                    if (txtDeepFryerSizeInGallons.Text.Trim().Length > 0)
                    {
                        deepFryer.SizeInGallons = Convert.ToDouble(txtDeepFryerSizeInGallons.Text.Trim());
                    }



                    deepFryer.Save();
                }
            }

            Response.Redirect("~/EditAccount.aspx?acctId=" + _account.AccountId.ToString());
        }
Esempio n. 3
0
        protected void btnSaveDeepFryer_Click(object sender, EventArgs e)
        {
            if (txtDeepFryerName.Text.Trim().Length > 0)
            {
                _currentFryer = new DeepFryerEntity(Convert.ToInt32(hdnDeepFryerId.Value));
                double sizeInGallons = 0;

                if (txtSizeInGallons.Text.Trim().Length > 0)
                {
                    try
                    {
                        sizeInGallons = Convert.ToDouble(txtSizeInGallons.Text.Trim());
                    }
                    catch
                    {
                        //TODO
                    }
                }
                _currentFryer.Name              = txtDeepFryerName.Text.Trim();
                _currentFryer.Description       = txtDeepFryerDescription.Text.Trim().Length > 0 ? txtDeepFryerDescription.Text.Trim() : null;
                _currentFryer.ServiceLocationId = _serviceLocation.ServiceLocationId;
                if (sizeInGallons > 0)
                {
                    _currentFryer.SizeInGallons = sizeInGallons;
                }
                else
                {
                    _currentFryer.SizeInGallons = null;
                }
                _currentFryer.Save();

                ChangeLogEntity cle = new ChangeLogEntity();
                cle.UserId       = sm.AuthenticatedUser.UserId;
                cle.ChangeDate   = DateTime.Now;
                cle.ChangeTypeId = (int)ChangeTypeEntity.ChangeTypes.FryerAdded;
                DeepFryerChangeLogEntity dfcle = new DeepFryerChangeLogEntity();
                dfcle.DeepFryerId = _currentFryer.DeepFryerId;
                dfcle.ChangeLog   = cle;
                dfcle.Save(true);

                rdFryersGrid.Rebind();
                divAddNewFryer.Visible = false;
                btnAddNewFryer.Visible = true;
                //    Response.Redirect("~/EditServiceLocation.aspx?serviceLocationId=" + _currentFryer.ServiceLocationId.ToString() + "&tab=1");
            }
        }