Exemple #1
0
        public ReturnModel PostBussiness(BussinessModel model)
        {
            ReturnModel retorno = new ReturnModel();

            retorno = _bussinessService.PostBussiness(model);
            return(retorno);
        }
Exemple #2
0
        private bool ValidateData(BussinessModel model)
        {
            bool retorno = true;

            if (!model.NameBussiness.Any())
            {
                retorno = false;
            }

            if (!model.Phone.Any())
            {
                retorno = false;
            }

            if (!model.Email.Any())
            {
                retorno = false;
            }

            if (!model.Document.Any())
            {
                retorno = false;
            }

            return(retorno);
        }
        public IActionResult GetEdit1Shangji(BussinessModel payload)
        {
            using (_dbContext)
            {
                var query = from b in _dbContext.Business
                            join c in _dbContext.Customer
                            on b.ClientUuid equals c.ClientUuid
                            join su in _dbContext.SystemUser
                            on c.ClientManager equals su.SystemUserUuid
                            where b.IsDelete == 0
                            select new
                {
                    b.Id,
                    b.BusinessUuid,
                    b.BusinessName,
                    b.BusinessStage,
                    b.SalesAmount,
                    b.Winrate,
                    b.BusinessSource,
                    b.BusinessType,
                    b.CheckTime,
                    b.Remarks,
                    b.SystemUserUuid,
                    b.ClientUuid,
                    Manager       = b.ClientUu.ClientManager,
                    clientName    = b.ClientUu.ClientName,
                    ClientManager = CooM(b.ClientUuid),
                    //ClientManager = su.RealName,

                    systemUserName = b.ContactBusName == null ? "" : (b.ContactBusName != null && b.ContactBusName != "") ? SelectNameLog(b.ContactBusName, _dbContext).Trim(',') : "",
                };
                if (AuthContextService.CurrentUser.RoleName != "超级管理员" && AuthContextService.CurrentUser.RoleName != "行业经理")
                {
                    query = query.Where(x => x.Manager == AuthContextService.CurrentUser.Guid);
                }
                if (!string.IsNullOrEmpty(payload.Kw))
                {
                    query = query.Where(x => x.BusinessName.Contains(payload.Kw));
                }

                if (string.IsNullOrEmpty(payload.stasources) && string.IsNullOrEmpty(payload.Kw) && string.IsNullOrEmpty(payload.Kw1))
                {
                    query = query.Where(x => x.BusinessStage.Contains("已关闭") == false);
                }
                if (!string.IsNullOrEmpty(payload.stasources))
                {
                    query = query.Where(x => x.BusinessStage.Contains(payload.stasources));
                }
                if (!string.IsNullOrEmpty(payload.Kw1))
                {
                    query = query.Where(x => x.clientName.Contains(payload.Kw1));
                }
                query = query.OrderByDescending(x => x.Id);
                var list       = query.Paged(payload.CurrentPage, payload.PageSize).ToList();
                var totalCount = query.Count();
                var response   = ResponseModelFactory.CreateResultInstance;
                response.SetData(list, totalCount);
                return(Ok(response));
            }
        }
        public IActionResult BusShow(BussinessModel payload)
        {
            var response = ResponseModelFactory.CreateResultInstance;

            using (_dbContext)
            {
                var query = from b in _dbContext.Business
                            where b.IsDelete == 0
                            select new
                {
                    b.Id,
                    b.BusinessUuid,
                    b.BusinessName,
                    b.BusinessStage,
                    b.SalesAmount,
                    b.Winrate,
                    b.BusinessSource,
                    b.BusinessType,
                    b.CheckTime,
                    b.Remarks,
                    b.SystemUserUuid,
                    b.ClientUuid,
                    clientName = b.ClientUu.ClientName,
                    b.ClientUu.ClientManager,
                    systemUserName = b.BusinessUuid == null ? "" : b.BusinessUuid != null?SelectName(b.BusinessUuid).Trim(',') : "",
                };

                // TODO:不可以硬编码,下个版本解决
                // 如果是我们指定的角色,可以查看所有的商机,否则只能看自己的商机
                if (AuthContextService.CurrentUser.RoleName != "超级管理员" && AuthContextService.CurrentUser.RoleName != "行业经理")
                {
                    query = query.Where(x => x.ClientManager == AuthContextService.CurrentUser.Guid);
                }
                //如果商机搜索框不为空,模糊匹配搜索框内容
                if (!string.IsNullOrEmpty(payload.BusinessName))
                {
                    query = query.Where(x => x.BusinessName.Contains(payload.BusinessName));
                }
                //页面加载自动把已关闭的商机筛选掉
                if (string.IsNullOrEmpty(payload.BusinessName) && string.IsNullOrEmpty(payload.Kw1))
                {
                    query = query.Where(x => x.BusinessStage.Contains("已关闭") == false);
                }
                //如果选择了状态,筛选处于当前状态的商机
                if (!string.IsNullOrEmpty(payload.Kw1))
                {
                    query = query.Where(x => x.BusinessStage.Contains(payload.Kw1));
                }
                //如果客户Uuid不为空,则只查询该客户的商机
                if (payload.ClientUUID != null)
                {
                    query = query.Where(x => x.ClientUuid == payload.ClientUUID);
                }
                query = query.OrderByDescending(x => x.Id);
                var demo = query.ToList();
                response.SetData(demo);
                return(Ok(response));
            }
        }
        public IActionResult DeleteInfo(string id)
        {
            dynamic a = new BussinessModel {
                Id = int.Parse(id)
            };

            _db.BussinessModels.Remove(a);
            _db.SaveChanges();
            return(Ok());
        }
Exemple #6
0
        public frmMainLogin()
        {
            InitializeComponent();


            Global.Instance.connectionState = BussinessModel.dbConnectionActive();

            this.Show();
            frmLogin login = new frmLogin(this);

            login.ShowDialog();
        }
Exemple #7
0
        public BussinessModel GetByIdBussiness(int id)
        {
            BussinessModel retorno = new BussinessModel();

            retorno = _bussinessRepository.GetByIdBussiness(id);

            if (retorno == null)
            {
                retorno.Retorno = "ID not exist";
            }

            return(retorno);
        }
Exemple #8
0
        private bool ValidateRegister(int id)
        {
            BussinessModel bussiness = new BussinessModel();
            var            retorno   = true;

            bussiness = _bussinessRepository.GetByIdBussiness(id);

            if (bussiness.BussinessId == 0)
            {
                retorno = false;
            }

            return(retorno);
        }
Exemple #9
0
        private void _validaUsuario()
        {
            if (txt_user.Text.Trim() == "" && txt_password.Text.Trim() == "")
            {
                ValidSAT.Classes.MessageBox.showAdviseModal("Proporcione el Nombre de Usuario y/o Contraseña por favor.");
                txt_user.Focus();
                return;
            }

            if (Global.Instance.connectionState == ConnectionState.Closed)
            {
                ValidSAT.Classes.MessageBox.showAdviseModal("Contacte al personal de ValidSAT. El servidor de base de datos no respode. Gracias");
                txt_user.Focus();
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;
                Global.Instance.userLogin = BussinessModel.ValidarUsuarioDeEmpresa(txt_user.Text, txt_password.Text);
            } catch (Exception e)
            {
                ValidSAT.Classes.MessageBox.showAdviseModal("Contacte al personal de ValidSAT. El servidor de base de datos no respode. Gracias");
                this.Show(); this.Focus();
                return;
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }

            if (Global.Instance.userLogin == null)
            {
                Classes.MessageBox.showAdviseModal("Verifique su Nombre de Usario tecleado, no se encuentra, o comuniquese con el personal de ValidSAT. Gracias");
                ingresarButton.BackgroundImage = global::ValidSAT.Properties.Resources.ingresar_off;
                txt_user.Focus();
                return;
            }

            Global.Instance.can_Alta = Global.Instance.userLogin.emp_aplicadespachocontable == 1 && BussinessModel.cantidadEmpresasAdministrados(Global.Instance.userLogin.emp_empresa) <= Global.Instance.userLogin.emp_rfcsampara;

            this.Visible = false;
            this._mainInstance.Visible = false;

            frmMainMenu main = new frmMainMenu();

            main.ShowDialog();
        }
Exemple #10
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public ActionResult ProductInStockMgt_Export(Mes_Stock_InStock obj)
        {
            var            list         = MesStockInStockDao.Instance.FindByCond(obj);
            BussinessModel bussinessObj = new BussinessModel();

            bussinessObj.BusinessType = "InStockMgt";
            KeyModel        keyObj  = null;
            List <KeyModel> colList = new List <KeyModel>();

            keyObj = new KeyModel("单据状态", "Show_AuditStatus");
            colList.Add(keyObj);
            keyObj = new KeyModel("检验状态", "Show_CheckStatus");
            colList.Add(keyObj);
            keyObj = new KeyModel("进货单别", "Show_BillType");
            colList.Add(keyObj);
            keyObj = new KeyModel("进货单号", "BillNo");
            colList.Add(keyObj);
            keyObj = new KeyModel("进货日期", "Show_InStockDate");
            colList.Add(keyObj);
            keyObj = new KeyModel("总进货数量", "TotalInStockNum");
            colList.Add(keyObj);
            keyObj = new KeyModel("总验收数量", "TotalAcceptNum");
            colList.Add(keyObj);
            keyObj = new KeyModel("供应商", "SupplierName");
            colList.Add(keyObj);
            keyObj = new KeyModel("供应商单号", "SupBillNo");
            colList.Add(keyObj);
            keyObj = new KeyModel("销售单别", "Show_SourceBillType");
            colList.Add(keyObj);
            keyObj = new KeyModel("销售单号", "SourceBillNo");
            colList.Add(keyObj);
            keyObj = new KeyModel("创建人", "Creater");
            colList.Add(keyObj);
            keyObj = new KeyModel("创建时间", "Show_CreatedTime");
            colList.Add(keyObj);
            bussinessObj.ColList = colList;
            string message = SysExportHelper.Export <Mes_Stock_InStock>(ref bussinessObj, list);

            if (!string.IsNullOrEmpty(message))
            {
                return(Json(new { IsSuccess = false, Message = message }));
            }
            return(Json(new { IsSuccess = true, Message = bussinessObj.FileName }));
        }
Exemple #11
0
        private void configurarApp()
        {
            long cntRFCEmpresas = BussinessModel.cantidadEmpresasAdministrados(Global.Instance.userLogin.emp_empresa);

            if (cntRFCEmpresas == 0)
            {
                ValidSAT.Classes.MessageBox.showAdviseModal("Hace falta registrar la empresa. Póngase en comunicación con el personal de ValidSAT. Gracias.");
            }

            rfcListado.DataSource = dataRfcAdministrados.DataSource = BussinessModel.getRfcAdministrados(this._empresa,
                                                                                                         Global.Instance.userLogin.emp_aplicadespachocontable == 1 && cntRFCEmpresas >= 1 &&
                                                                                                         cntRFCEmpresas <= Global.Instance.userLogin.emp_rfcsampara
                                                                                                         );


            if (((IList)rfcListado.DataSource).Count == 0 && Global.Instance.userLogin.emp_aplicadespachocontable == 1)
            {
                ValidSAT.Classes.MessageBox.showAdviseModal("No se pueden encontrar los datos de la empresa. Por favor avise sobre este mensaje a nuestra área de soporte tècnico. Gracias");
            }

            if (((IList)rfcListado.DataSource).Count > 1)
            {
                rfcListado.SelectedIndex = 1;
            }

            if (Global.Instance.userLogin.emp_aplicadespachocontable == 1 && BussinessModel.ExistenRfcAdministrados(this._empresa))
            {
                dataRfcAdministrados.Rows[0].Visible = false;
            }

            rfcListado.Visible          = false;
            CodigoPostalListado.Visible = false;
            emailServerList.Visible     = false;

            page = 8;
            _clearOption();
            opt_configurarApp.Image     = global::ValidSAT.Properties.Resources.b8;
            panel_ConfigurarApp.Visible = true;
        }
        public ReturnModel PostBussiness(BussinessModel model)
        {
            ReturnModel retorno = new ReturnModel();


            string sqlQuery = @"insert into bussines values(@NameBussiness, @Phone, @Email, @Document);
                                SELECT TOP 1 bussinessid FROM bussines ORDER BY bussinessid DESC;";

            retorno.BusssinessId = conn.Query <int>(sqlQuery, model).Single();

            if (retorno.BusssinessId != 0)
            {
                retorno.Retorno = "Dados inseridos!";
                return(retorno);
            }
            else
            {
                retorno.Retorno = "Errrrou";
            }

            return(retorno);
        }
Exemple #13
0
        public ReturnModel PostBussiness(BussinessModel model)
        {
            ReturnModel retorno = new ReturnModel();

            try
            {
                if (ValidateData(model))
                {
                    retorno = _bussinessRepository.PostBussiness(model);
                    return(retorno);
                }
                else
                {
                    retorno.Retorno = "Unfilled data";
                    return(retorno);
                }
            }
            catch (Exception ex)
            {
                retorno.Retorno = ex.Message;
                return(retorno);
            }
        }
Exemple #14
0
        private bool storeData()
        {
            try
            {
                if (txt_RFC.Text.Trim() == "")
                {
                    ValidSAT.Classes.MessageBox.showAdviseModal("Inserte el nuevo código RFC por favor.");
                    txt_RFC.Focus();
                    return(false);
                }

                string correo = "";
                if (txt_correo_electronico.Text.Trim().Length != 0)
                {
                    if (servidor.Text == "")
                    {
                        ValidSAT.Classes.MessageBox.showAdviseModal("Seleccione el servidor de correo por favor.");
                        emailServerList.Show();
                        emailServerList.Focus();
                        return(false);
                    }
                    else if (txt_correo_electronico.Text.IndexOf("@") > 0)
                    {
                        correo = txt_correo_electronico.Text.Substring(0, txt_correo_electronico.Text.IndexOf('@'));
                    }
                    else
                    {
                        correo = txt_correo_electronico.Text;
                    }
                }

                if (txt_CodigoPostal.Text.Trim() == "")
                {
                    ValidSAT.Classes.MessageBox.showAdviseModal("Seleccione el Código Postal por favor.");
                    txt_CodigoPostal.Focus();
                    return(false);
                }


                if (txt_RFC.Text.Trim().Length == 0)
                {
                    ValidSAT.Classes.MessageBox.showAdviseModal("El campo RFC es obligatorio.");
                    txt_RFC.Focus();
                    return(false);
                }

                if (txt_nombre.Text.Trim().Length == 0)
                {
                    ValidSAT.Classes.MessageBox.showAdviseModal("El nombre de la Persona Fiscal o Moral es obligatorio.");
                    txt_RFC.Focus();
                    return(false);
                }

                if (switch1.KeyValue == 0)
                {
                    label34.Text = label51.Text = txt_contrasena_CIEC.Text = txt_contrasena_key.Text = "";
                }

                if (panel3.Visible)
                {
                    BussinessModel.storeConfigApp(txt_RFC.Text, txt_nombre.Text, correo, servidor.Text, txt_contrasena.Text, txt_CodigoPostal.Text, txt_contrasena_CIEC.Text, txt_contrasena_key.Text, label34.Text, label51.Text, ((cnf_rfcadministrados)rfcListado.SelectedItem).rfc_rfcempresa);
                }

                long cntRFCEmpresas = BussinessModel.cantidadEmpresasAdministrados(Global.Instance.userLogin.emp_empresa);
                List <cnf_rfcadministrados> listado = BussinessModel.getRfcAdministrados(this._empresa, Global.Instance.userLogin.emp_aplicadespachocontable == 1 && cntRFCEmpresas >= 1 && cntRFCEmpresas <= Global.Instance.userLogin.emp_rfcsampara);

                rfcListado.DataSource    = null;
                rfcListado.DisplayMember = "displayMember";
                rfcListado.DataSource    = listado;

                //listado.RemoveAt(0);
                dataRfcAdministrados.DataSource = listado;

                if (listado.Count > 1)
                {
                    rfcListado.SelectedIndex = listado.Count - 1;
                }

                if (BussinessModel.cantidadEmpresasAdministrados(Global.Instance.userLogin.emp_empresa) >= Global.Instance.userLogin.emp_rfcsampara)
                {
                    if (((IList <cnf_rfcadministrados>)rfcListado.DataSource)[0].rfc_nombreempresa == "  Agregar Empresa")
                    {
                        ((IList <cnf_rfcadministrados>)rfcListado.DataSource).RemoveAt(0);
                    }
                }
            }
            catch (FormatException ex)
            {
                ValidSAT.Classes.MessageBox.showAdviseModal("Inserte un correo electrónico válido.");
                return(false);
            }
            catch (RfcExistsException ex)
            {
                ValidSAT.Classes.MessageBox.showAdviseModal("El valor RFC de empresa insertado ya existe.");
                txt_RFC.Focus();
                return(false);
            }

            return(true);
            //setEditState(false);
        }
Exemple #15
0
        /// <summary>
        /// 通用导出
        /// </summary>
        /// <param name="businessObj"></param>
        public static string Export <T>(ref BussinessModel businessObj, List <T> list) where T : class
        {
            string message = string.Empty;

            try
            {
                //1.生成文件(由模板生成新的文件)
                string templateName = "ExportTemplate.xls";
                string templatePath = HttpContext.Current.Server.MapPath("~" + SysConfigHelper.TemplateFolder) + templateName;
                string tempPath     = HttpContext.Current.Server.MapPath("~" + SysConfigHelper.TempFolder);
                string fileName     = string.Format("{0}_{1}.xls", businessObj.BusinessType, DateTime.Now.ToString("yyMMddHHmmssffff"));
                businessObj.FilePath = tempPath + fileName;
                businessObj.FileName = fileName;
                message = FileHelper.CopyFile(templatePath, tempPath.Trim('/'), fileName);
                if (!string.IsNullOrEmpty(message))
                {
                    return(message);
                }

                //2.填写文件内容
                CellDLL.Workbook workbook = new CellDLL.Workbook(businessObj.FilePath);
                CellDLL.Cells    cells    = workbook.Worksheets[0].Cells;//单元格
                int    index  = 0;
                int    colNum = 0;
                object value  = null;
                IDictionary <string, PropertyInfo> colProperties = new Dictionary <string, PropertyInfo>();
                PropertyInfo property = null;
                Type         type     = typeof(T);
                if (businessObj.ColList != null && businessObj.ColList.Count > 0)
                {
                    //(1)先写列头
                    businessObj.ColList.ForEach(item =>
                    {
                        cells[index, colNum++].Value = item.Value;
                        if (!colProperties.ContainsKey(item.Key))
                        {
                            property = type.GetProperty(item.Key);
                            colProperties.Add(item.Key, property);
                        }
                    });

                    //(2)写内容
                    if (list != null && list.Count > 0)
                    {
                        index  = 1;
                        colNum = 0;
                        foreach (var item in list)
                        {
                            foreach (KeyModel keyObj in businessObj.ColList)
                            {
                                property = colProperties[keyObj.Key];
                                if (property != null)
                                {
                                    value = property.GetValue(item, null);
                                    cells[index, colNum].Value = TConvertHelper.FormatDBString(value);
                                }

                                colNum++;
                            }
                            colNum = 0;
                            index++;
                        }
                    }
                }/*businessObj.ColList*/

                //3.保存文件
                workbook.Save(businessObj.FilePath);
            }
            catch (Exception ex)
            {
                return("导出文件时出错,文件可能正被打开!");
            }
            finally
            {
                //xlApp.Quit();
                GC.Collect();//强行销毁
            }

            return(string.Empty);
        }
Exemple #16
0
 public FunctionOpenResult <bool> UpdateByID(BussinessModel info)
 {
     throw new NotImplementedException();
 }
Exemple #17
0
 public FunctionResult <BussinessModel> Create(BussinessModel info)
 {
     throw new NotImplementedException();
 }
Exemple #18
0
 void initCodigoPostal()
 {
     CodigoPostalListado.DataSource = BussinessModel.dameCodigosPostales(0, 1000);
 }
Exemple #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string businessType = Request.Params["BusinessType"];
                string keyValue     = Request.Params["KeyValue"];
                string isExport     = Request.Params["IsExport"];
                string fileName     = Request.Params["FileName"];
                if (string.IsNullOrEmpty(businessType))
                {
                    Response.Clear();
                    Response.Write("导出失败,缺少业务类型参数!");
                    Response.End();
                    return;
                }
                //获取临时文件物理路径
                string tempPath = Server.MapPath("~" + SysConfigHelper.TempFolder);

                //LTSampleInfoExt obj = new LTSampleInfoExt();
                ////  var paramm = batch + "|" + sample + "|" + projectId + "|" + yearcom + "|";
                //obj.Batch = ConvertHelper.FormatDBString( Request.Params["Batch"]);
                //obj.SampleId =ConvertHelper.FormatDBString( Request.Params["SampleId"]);
                //obj.ProjectId =ConvertHelper.FormatDBInt( Request.Params["ProjectId"]);
                //obj.Year =Request.Params["Year"];

                ////
                //obj.userName = Request.Params["usrName"];

                //1.生成文件
                BussinessModel businessObj = new BussinessModel();
                businessObj.BusinessType = businessType;
                businessObj.TempPath     = tempPath;
                //显示返回的消息
                string message = string.Empty;

                //switch (businessType)
                //{
                //    case "BatchSampleRpt": //批量导出样品信息
                //        message = this.GenBatchSampleReport(businessObj);
                //        break;
                //    case "SingleSampleRpt": //导出单个样品信息
                //        businessObj.KeyValue = keyValue;
                //        message = this.GenSingleSampleReport(businessObj);
                //        break;
                //    default:
                //        message = this.GenSingleSampleReport(businessObj);
                //        break;
                //}

                if (isExport == "1") //直接导出
                {
                    businessObj.FilePath = tempPath + fileName;
                }

                //2.输出文件
                System.IO.FileInfo file = new System.IO.FileInfo(businessObj.FilePath);
                Response.Clear();
                Response.Charset         = "UTF-8";
                Response.ContentEncoding = System.Text.Encoding.Default;
                // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
                // 添加头信息,指定文件大小,让浏览器能够显示下载进度
                Response.AddHeader("Content-Length", file.Length.ToString());
                Response.ContentType = "application/octet-stream";
                // 把文件流发送到客户端
                Response.WriteFile(file.FullName);

                //MemoryStream stream = new MemoryStream(); // OutFileToStream(ModelDB.dbDT);
                //byte[] bytes = stream.ToArray();
                //Response.ContentType = "application/octet-stream";
                ////通知浏览器下载文件而不是打开
                //Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("23.xls", Encoding.UTF8));
                //Response.BinaryWrite(bytes);
            }

            Response.Flush();
            Response.End();
        }
 public IActionResult UpdateBussines(BussinessModel bs)
 {
     _db.BussinessModels.Add(bs);
     _db.SaveChanges();
     return(View("Bussiness"));
 }