Beispiel #1
0
        public static bool IsNameAvailable(entitiesEvolveCentral ctx, string value, int?id)
        {
            bool retval = true;

            try
            {
                DAL.ServiceTemplateCrmEvolutionItem item = (from i in ctx.ServiceTemplateCrmEvolutionItems where i.Name.ToUpper() == value.ToUpper() select i).FirstOrDefault();
                if (item != null)
                {
                    if (id == null)
                    {
                        retval = false;
                    }

                    if (id != null && item.Id != id)
                    {
                        retval = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.Log(ctx, "DAL.ServiceTemplateCrmEvolution.IsNameAvailable(entitiesEvolveCentral ctx, string value, int? id)", ex.Message);
                retval = false;
            }

            return(retval);;
        }
        void DeleteItem(int itemid)
        {
            DAL.ServiceTemplateCrmEvolutionItem item = DAL.ServiceTemplateCrmEvolution.Get(ctx, itemid);
            bool succeded = DAL.ServiceTemplateCrmEvolution.Delete(ctx, item);

            rgvData.Rebind();
        }
        public static bool DeleteByService(entitiesEvolveCentral ctx, int id, bool deleteUnique)
        {
            var item = new ServiceCrmEvolutionDetailItem();

            try
            {
                DAL.ServiceCrmEvolutionItem sitem = DAL.ServiceCrmEvolution.Get(ctx, id);

                DAL.ServiceTemplateCrmEvolutionItem stitem = DAL.ServiceTemplateCrmEvolution.Get(ctx, Convert.ToInt32(sitem.ServiceTemplateCrmEvolutionId));

                List <DAL.ServiceCrmEvolutionDetailItem> detailitems = DAL.ServiceCrmEvolutionDetail.GetByService(ctx, id);
                for (int i = 0; i < detailitems.Count; i++)
                {
                    int detailid = detailitems[i].Id;
                    DAL.ServiceCrmEvolutionDetailItem sditem = ctx.ServiceCrmEvolutionDetailItems.Find(detailid);
                    if (deleteUnique)
                    {
                        ctx.ServiceCrmEvolutionDetailItems.Remove(sditem);
                    }
                    else
                    {
                        if (!Convert.ToBoolean(sditem.IsUnique))
                        {
                            ctx.ServiceCrmEvolutionDetailItems.Remove(sditem);
                        }
                    }
                }
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        void LoadData()
        {
            string id = GetId();

            DAL.ServiceTemplateCrmEvolutionItem item = DAL.ServiceTemplateCrmEvolution.Get(ctx, Convert.ToInt32(id));

            if (item != null)
            {
                txtId.Text          = item.Id.ToString();
                txtCode.Text        = item.Code;
                txtName.Text        = item.Name;
                txtDescription.Text = item.Description;
                txtServiceType.Text = item.ServiceTypeItem.Name;
                txtActive.Text      = (item.IsActive) ? "Yes" : "No";
            }
        }
        void LoadData()
        {
            string id = (Request.QueryString["id"] != null && !string.IsNullOrEmpty(Request.QueryString["id"])) ? Request.QueryString["id"].ToString() : null;

            DAL.ServiceTemplateCrmEvolutionItem item = DAL.ServiceTemplateCrmEvolution.Get(ctx, Convert.ToInt32(id));

            if (item != null)
            {
                txtId.Text          = item.Id.ToString();
                txtCode.Text        = item.Code;
                txtName.Text        = item.Name;
                txtDescription.Text = item.Description;
                txtServiceType.Text = item.ServiceTypeItem.Name;
                chkActive.Checked   = item.IsActive;
            }
        }
        public static bool Revert(entitiesEvolveCentral ctx, int id)
        {
            var item = new ServiceCrmEvolutionItem();

            try
            {
                DAL.ServiceCrmEvolutionItem sitem = Get(ctx, id);

                DAL.ServiceTemplateCrmEvolutionItem stitem = DAL.ServiceTemplateCrmEvolution.Get(ctx, Convert.ToInt32(sitem.ServiceTemplateCrmEvolutionId));

                DAL.ServiceCrmEvolutionDetail.DeleteByService(ctx, id, false);



                DateTime cdate = DateTime.Now;

                foreach (DAL.ServiceTemplateCrmEvolutionDetailItem i in stitem.ServiceTemplateCrmEvolutionDetailItems)
                {
                    DAL.ServiceCrmEvolutionDetailItem newitem = new DAL.ServiceCrmEvolutionDetailItem();
                    newitem.IsActive    = i.IsActive;
                    newitem.Code        = i.Code;
                    newitem.Command     = i.Command;
                    newitem.IsUnique    = false;
                    newitem.CommandType = i.CommandType;

                    newitem.Description      = i.Description;
                    newitem.DestinationTable = i.DestinationTable;

                    newitem.Name     = i.Name;
                    newitem.Sequence = i.Sequence;
                    newitem.ServiceCrmEvolutionId = sitem.Id;
                    newitem.SourceTable           = i.SourceTable;

                    if (DAL.ServiceCrmEvolutionDetail.GetByServiceAndCode(ctx, Convert.ToInt32(newitem.ServiceCrmEvolutionId), newitem.Code).Count == 0)
                    {
                        DAL.ServiceCrmEvolutionDetail.Save(ctx, newitem);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Beispiel #7
0
        bool Save()
        {
            if (!IsValid())
            {
                return(false);
            }

            DateTime currentdate = DateTime.Now;

            var item = new DAL.ServiceTemplateCrmEvolutionItem();

            item.Code          = txtCode.Text;
            item.Name          = txtName.Text;
            item.Description   = txtDescription.Text;
            item.ServiceTypeId = DAL.ServiceType.GetByCode(ctx, Helper.Constant.CODE_SERVICE_CRMEVOLUTION).Id;
            item.IsActive      = chkActive.Checked;


            bool succeeded = DAL.ServiceTemplateCrmEvolution.Save(ctx, item);

            return(succeeded);
        }