예제 #1
0
        public void EditDataBlood(string bloodSerial, string bloodGroup, string section, ShafaCommon.Types.ShafaDateType editDate, out string message)
        {
            message = string.Empty;

            DAL.Model.DatabaseContext databaseContext = null;
            try
            {
                databaseContext =
                    new DAL.Model.DatabaseContext();

                #region Validation
                if (string.IsNullOrWhiteSpace(bloodSerial))
                {
                    message =
                        BloodBusinessLogicalLayer.Properties.Resources.validationBloodSerial;
                }

                if (string.IsNullOrWhiteSpace(message) == false)
                {
                    ShafaCommon.Common.MessageManager.ShowMessageBox
                        (message);
                    return;
                }
                #endregion /Validation

                DAL.Model.Blood blood =
                    databaseContext.Bloods
                    .Where(current => string.Compare(current.BloodSerial, bloodSerial) == 0)
                    .FirstOrDefault();

                if (blood == null)
                {
                    ShafaCommon.Common.MessageManager.ShowMessageBox
                        (BloodBusinessLogicalLayer.Properties.Resources.stringNotFoundBlood);
                    return;
                }
                else
                {
                    blood.BloodSerial = bloodSerial;
                    blood.BloodGorup  = bloodGroup;
                    blood.Section     = section;
                    blood.EditDate    = editDate.ToString();
                }

                databaseContext.SaveChanges();

                ShafaCommon.Common.MessageManager.ShowMessageBox
                    (BloodBusinessLogicalLayer.Properties.Resources.stringEditBlood);
            }
            catch (Exception ex)
            {
                ShafaCommon.Common.ExceptionManager.ManageException(ex);
            }
        }
예제 #2
0
        public void DeletDataBlood(string bloodSerial, out string message)
        {
            message = string.Empty;

            DAL.Model.DatabaseContext databaseContext = null;
            try
            {
                databaseContext =
                    new DAL.Model.DatabaseContext();

                #region Validation
                if (string.IsNullOrWhiteSpace(bloodSerial))
                {
                    message =
                        BloodBusinessLogicalLayer.Properties.Resources.validationBloodSerial;
                }

                if (string.IsNullOrWhiteSpace(message) == false)
                {
                    ShafaCommon.Common.MessageManager.ShowMessageBox
                        (message);
                    return;
                }
                #endregion /Validation

                DAL.Model.Blood blood =
                    databaseContext.Bloods
                    .Where(current => string.Compare(current.BloodSerial, bloodSerial) == 0)
                    .FirstOrDefault();

                if (blood == null)
                {
                    ShafaCommon.Common.MessageManager.ShowMessageBox
                        (BloodBusinessLogicalLayer.Properties.Resources.stringNotFoundBlood);
                    return;
                }
                else
                {
                    databaseContext.Bloods.Remove(blood);
                    databaseContext.SaveChanges();
                }


                ShafaCommon.Common.MessageManager.ShowMessageBox
                    (BloodBusinessLogicalLayer.Properties.Resources.stringFoundBlood);
            }
            catch (Exception ex)
            {
                ShafaCommon.Common.ExceptionManager.ManageException(ex);
            }
        }
예제 #3
0
        public void SaveDataBlood(string bloodSerial, string bloodGroup, string section, ShafaCommon.Types.ShafaDateType registerDate, out string message)
        {
            message = string.Empty;

            DAL.Model.DatabaseContext databaseContext = null;
            try
            {
                databaseContext =
                    new DAL.Model.DatabaseContext();

                #region Validation
                if (string.IsNullOrWhiteSpace(bloodSerial))
                {
                    message =
                        BloodBusinessLogicalLayer.Properties.Resources.validationBloodSerial;
                }
                if (string.IsNullOrWhiteSpace(bloodGroup))
                {
                    if (string.IsNullOrWhiteSpace(message) == false)
                    {
                        message +=
                            System.Environment.NewLine;
                    }
                    message +=
                        BloodBusinessLogicalLayer.Properties.Resources.validationBloodGroup;
                    return;
                }
                if (string.IsNullOrWhiteSpace(section.ToString()))
                {
                    if (string.IsNullOrWhiteSpace(message) == false)
                    {
                        message +=
                            System.Environment.NewLine;
                    }
                    message +=
                        BloodBusinessLogicalLayer.Properties.Resources.validationSection;
                    return;
                }
                if (string.IsNullOrWhiteSpace(registerDate.ToString()))
                {
                    if (string.IsNullOrWhiteSpace(message) == false)
                    {
                        message +=
                            System.Environment.NewLine;
                    }
                    message +=
                        BloodBusinessLogicalLayer.Properties.Resources.validationRegisterDate;
                }

                if (string.IsNullOrWhiteSpace(message) == false)
                {
                    ShafaCommon.Common.MessageManager.ShowMessageBox
                        (message);
                    return;
                }
                #endregion /Validation

                DAL.Model.Blood blood =
                    databaseContext.Bloods
                    .Where(current => string.Compare(current.BloodSerial, bloodSerial) == 0)
                    .FirstOrDefault();

                if (blood != null)
                {
                    ShafaCommon.Common.MessageManager.ShowMessageBox
                        (BloodBusinessLogicalLayer.Properties.Resources.stringFoundBlood);
                    return;
                }
                else
                {
                    blood =
                        new DAL.Model.Blood
                    {
                        BloodSerial  = bloodSerial,
                        BloodGorup   = bloodGroup,
                        Section      = section,
                        RegisterDate = registerDate.ToString(),
                        EditDate     = string.Empty,
                    };
                }
                databaseContext.Bloods.Add(blood);
                databaseContext.SaveChanges();

                ShafaCommon.Common.MessageManager.ShowMessageBox
                    (BloodBusinessLogicalLayer.Properties.Resources.stringSaveBlood);
            }
            catch (Exception ex)
            {
                ShafaCommon.Common.ExceptionManager.ManageException(ex);
            }
        }