protected void bt_RevocationApply_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] == 0)
        {
            MessageBox.Show(this, "对不起,请您先保存后在发起申请");
            return;
        }
        //判断是否还有未审批流程
        if (EWF_Task_JobDecisionBLL.GetModelList("DecisionResult=1 AND RecipientStaff=" + ViewState["ID"].ToString()).Count > 0)
        {
            MessageBox.Show(this, "对不起,该人员还有未审批流程,暂不能发起离职流程!");
            return;
        }


        Org_StaffBLL        bll         = new Org_StaffBLL((int)ViewState["ID"]);
        NameValueCollection dataobjects = new NameValueCollection();

        dataobjects.Add("ID", ViewState["ID"].ToString());
        dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
        dataobjects.Add("Position", bll.Model.Position.ToString());
        dataobjects.Add("StaffName", bll.Model.RealName.ToString());
        int TaskID = EWF_TaskBLL.NewTask("Revocation_Staff",
                                         (int)Session["UserID"],
                                         TreeTableBLL.GetSuperNameByLevel("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "Name", "SuperID", bll.Model.OrganizeCity, ConfigHelper.GetConfigInt("OrganizePartCity-CityLevel")) +
                                         "  " + TreeTableBLL.GetSuperNameByLevel("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "Name", "SuperID", bll.Model.OrganizeCity, ConfigHelper.GetConfigInt("OrganizeCity-CityLevel")) + " " +
                                         new Org_PositionBLL(bll.Model.Position).Model.Name + " " +
                                         bll.Model.RealName + " 离职申请", "~/SubModule/StaffManage/StaffDetail.aspx?ID="
                                         + ViewState["ID"].ToString(), dataobjects);

        if (TaskID > 0)
        {
            bll.Model["TaskID"] = TaskID.ToString();
            bll.Model["State"]  = "2";
            bll.Update();
        }
        Response.Redirect("~/SubModule/EWF/Apply.aspx?TaskID=" + TaskID.ToString());
    }
    protected void bt_RevocationApply_Click(object sender, EventArgs e)
    {
        #region 判断有无下游客户
        if (CM_ClientBLL.GetModelList("Supplier=" + ViewState["ClientID"].ToString() + " AND ActiveFlag=1").Count > 0)
        {
            MessageBox.Show(this, "对不起,该经销商下还有活跃的下游分销商或门店,无法申请撤销!");
            return;
        }
        #endregion
        if (new FNA_FeeApplyBLL().GetDetail(@" Flag IN(1,2,4) AND AvailCost>0 AND EXISTS 
            (SELECT ID FROM MCS_FNA.dbo.FNA_FeeApply WHERE State=3 AND ApproveFlag=1 AND ID=FNA_FeeApplyDetail.ApplyID
            AND Client=" + ViewState["ClientID"] + ")").Count > 0)
        {
            MessageBox.Show(this, "该经销商下还有费用未做核销,请核销后再撤销!");
            return;
        }

        CM_ClientBLL        bll         = new CM_ClientBLL((int)ViewState["ClientID"]);
        NameValueCollection dataobjects = new NameValueCollection();
        dataobjects.Add("ID", ViewState["ClientID"].ToString());
        dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
        dataobjects.Add("ClientName", bll.Model.FullName.ToString());
        dataobjects.Add("CloseTime", DateTime.Now.ToShortDateString());
        dataobjects.Add("Remark", "经销商终止合作");
        dataobjects.Add("OperateClassify", bll.Model["OperateClassify"]);
        dataobjects.Add("DIClassify", bll.Model["DIClassify"]);

        string Title  = TreeTableBLL.GetSuperNameByLevel("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "Name", "SuperID", bll.Model.OrganizeCity, ConfigHelper.GetConfigInt("OrganizeCity-CityLevel")) + "-" + "经销商中止合作流程";//办事处+经分销商名称+中止流程
        int    TaskID = EWF_TaskBLL.NewTask("Revocation_Distributor", (int)Session["UserID"], Title, "~/SubModule/CM/DI/DistributorDetail.aspx?ClientID=" + ViewState["ClientID"].ToString(), dataobjects);
        if (TaskID > 0)
        {
            bll.Model["TaskID"] = TaskID.ToString();
            bll.Model["State"]  = "2";
            bll.Update();
        }

        Response.Redirect("~/SubModule/EWF/Apply.aspx?TaskID=" + TaskID.ToString());
    }
Example #3
0
        /// <summary>
        /// Bind data to the control from the special model
        /// </summary>
        /// <param name="_model"></param>
        public void BindData(IModel _model)
        {
            if (_model == null || _model["ID"] == string.Empty)
            {
                return;
            }

            foreach (object _key in FieldControlsInfo.Keys)
            {
                FieldControlInfo fieldcontrolinfo = (FieldControlInfo)FieldControlsInfo[_key];
                string           fieldname        = fieldcontrolinfo.FieldName;

                if (fieldcontrolinfo.ModelName == _model.ModelName)
                {
                    try
                    {
                        UD_Panel_ModelFields _panelfield = new UD_Panel_ModelFieldsBLL(fieldcontrolinfo.Panel_Field_ID, true).Model;
                        UD_ModelFields       _modelfield = new UD_ModelFieldsBLL(fieldcontrolinfo.FieldID, true).Model;
                        string _formatstring             = _panelfield.FormatString;

                        switch (fieldcontrolinfo.ControlType)
                        {
                        case 1:     //Label控件
                            //判断是否显示关联表的文本值
                            if (fieldcontrolinfo.DisplayMode == 1)
                            {
                                if (_modelfield.DataType == 1)
                                {
                                    ((Label)this.FindControl((string)_key)).Text = int.Parse(_model[fieldname]).ToString(_formatstring);
                                }
                                else if (_modelfield.DataType == 2)
                                {
                                    ((Label)this.FindControl((string)_key)).Text = decimal.Parse(_model[fieldname]).ToString(_formatstring);
                                }
                                else if (_modelfield.DataType == 4)
                                {
                                    if (DateTime.Parse(_model[fieldname]) != new DateTime(1900, 1, 1))
                                    {
                                        ((Label)this.FindControl((string)_key)).Text = DateTime.Parse(_model[fieldname]).ToString(_formatstring);
                                    }
                                }
                                else
                                {
                                    ((Label)this.FindControl((string)_key)).Text = _model[fieldname];
                                }
                            }
                            else
                            {
                                if (_panelfield.TreeLevel > 0 && new UD_TableListBLL(_modelfield.RelationTableName).Model.TreeFlag == "Y")
                                {
                                    #region 字段关联到树形结构表,且要显示上层父结点信息
                                    int value = 0;
                                    if (int.TryParse(_model[fieldname], out value))
                                    {
                                        if (_panelfield.TreeLevel == 100)
                                        {
                                            //显示全路径
                                            ((Label)this.FindControl((string)_key)).Text = TreeTableBLL.GetFullPathName(_modelfield.RelationTableName, value);
                                        }
                                        else
                                        {
                                            //显示父级
                                            ((Label)this.FindControl((string)_key)).Text = TreeTableBLL.GetSuperNameByLevel(_modelfield.RelationTableName, value, _panelfield.TreeLevel);
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    ((Label)this.FindControl((string)_key)).Text = GetRelateTextByValue(_modelfield, _model[fieldname]);
                                }
                            }
                            break;

                        case 2:     //TextBox
                        case 5:     //MultiRowTextBox
                            if (_modelfield.DataType == 1)
                            {
                                ((TextBox)this.FindControl((string)_key)).Text = int.Parse(_model[fieldname]).ToString(_formatstring);
                            }
                            else if (_modelfield.DataType == 2)
                            {
                                ((TextBox)this.FindControl((string)_key)).Text = decimal.Parse(_model[fieldname]).ToString(_formatstring);
                            }
                            else if (_modelfield.DataType == 4)
                            {
                                if (DateTime.Parse(_model[fieldname]) != new DateTime(1900, 1, 1))
                                {
                                    ((TextBox)this.FindControl((string)_key)).Text = DateTime.Parse(_model[fieldname]).ToString(_formatstring);
                                }
                            }
                            else
                            {
                                ((TextBox)this.FindControl((string)_key)).Text = _model[fieldname];
                            }
                            break;

                        case 3:     //DropDownList
                            if (_model[fieldname] != "")
                            {
                                ((DropDownList)this.FindControl((string)_key)).SelectedValue = _model[fieldname];
                            }
                            break;

                        case 4:     //RadioButtonList
                            if (_model[fieldname] != "")
                            {
                                ((RadioButtonList)this.FindControl((string)_key)).SelectedValue = _model[fieldname];
                            }
                            break;

                        case 6:     //带选择功能的控件
                            if (_model[fieldname] != "")
                            {
                                ((MCSSelectControl)this.FindControl((string)_key)).SelectValue = _model[fieldname];
                                ((MCSSelectControl)this.FindControl((string)_key)).SelectText  = GetRelateTextByValue(_modelfield, _model[fieldname]);
                            }
                            break;

                        case 7:     //树形选择控件
                            if (_model[fieldname] != "")
                            {
                                ((MCSTreeControl)this.FindControl((string)_key)).SelectValue = _model[fieldname];
                            }
                            break;
                        }
                    }
                    catch { }
                }
            }
        }
        public void BindGrid()
        {
            FillDataSource();
            DataBind();
            Binded = true;

            if (PanelCode != "" && ViewState["TreeColumn"] != null)
            {
                Dictionary <string, UD_Panel_ModelFields> dicTreeColumnList = (Dictionary <string, UD_Panel_ModelFields>)ViewState["TreeColumn"];
                for (int i = 0; i < Columns.Count; i++)
                {
                    DataControlField column = Columns[i];

                    if (column.GetType().Name == "BoundField")
                    {
                        BoundField field = (BoundField)column;
                        if (!column.Visible)
                        {
                            continue;
                        }

                        foreach (GridViewRow row in Rows)
                        {
                            if (row.Cells[i].Text.StartsWith("1900-01-01"))
                            {
                                row.Cells[i].Text = "";
                            }
                        }

                        if (!dicTreeColumnList.ContainsKey(field.DataField))
                        {
                            continue;
                        }

                        UD_Panel_ModelFields     _panel_modelfields = dicTreeColumnList[field.DataField];
                        Dictionary <int, string> cachevalue         = new Dictionary <int, string>();

                        foreach (GridViewRow row in Rows)
                        {
                            int value = 0;
                            if (int.TryParse(row.Cells[i].Text, out value))
                            {
                                if (cachevalue.ContainsKey(value))
                                {
                                    row.Cells[i].Text = cachevalue[value];
                                }
                                else
                                {
                                    if (_panel_modelfields.TreeLevel == 100)
                                    {
                                        //显示全路径
                                        row.Cells[i].Text = TreeTableBLL.GetFullPathName(new UD_ModelFieldsBLL(_panel_modelfields.FieldID, true).Model.RelationTableName, value);
                                    }
                                    else
                                    {
                                        //显示父级
                                        if (_panel_modelfields.DisplayMode == 1)
                                        {
                                            row.Cells[i].Text = TreeTableBLL.GetSuperIDByLevel(new UD_ModelFieldsBLL(_panel_modelfields.FieldID, true).Model.RelationTableName, value, _panel_modelfields.TreeLevel).ToString();
                                        }
                                        else
                                        {
                                            row.Cells[i].Text = TreeTableBLL.GetSuperNameByLevel(new UD_ModelFieldsBLL(_panel_modelfields.FieldID, true).Model.RelationTableName, value, _panel_modelfields.TreeLevel);
                                        }
                                    }
                                    cachevalue.Add(value, row.Cells[i].Text);
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 获取数据源
        /// </summary>
        /// <param name="ParamValue"></param>
        /// <param name="CacheTime"></param>
        /// <returns></returns>
        public DataTable GetData(Dictionary <string, object> ParamValue, bool LoadFromCache, out DateTime CacheTime)
        {
            DataTable dt = null;

            CacheTime = DateTime.Now;

            if (LoadFromCache)
            {
                dt = Rpt_DataSet_DataCacheBLL.LoadDataSetCache(_m.ID, ParamValue, out CacheTime);
            }

            if (dt == null || dt.Rows.Count == 0)
            {
                SqlParameter[] param = MakeParams(ParamValue);

                Rpt_DataSource source = new Rpt_DataSourceBLL(_m.DataSource).Model;
                string         conn   = "";

                if (source.ConnectionString != "")
                {
                    conn = MCSFramework.Common.DataEncrypter.DecryptData(source.ConnectionString);
                }

                switch (_m.CommandType)
                {
                case 1:
                    dt = _dal.GetDataFromSQL(conn, _m.CommandText, param);
                    break;

                case 2:
                    dt = _dal.GetDataFromStoreProcedure(conn, _m.CommandText, param);
                    break;

                case 3:
                    Dictionary <string, Rpt_DataSetFields> dicTreeColumnList;
                    dt = _dal.GetDataFromSQL(conn, GenarateSelectSQL(out dicTreeColumnList), param);

                    #region 处理树形字段,显示指定层级的内容
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        DataColumn column = dt.Columns[i];

                        if (!dicTreeColumnList.ContainsKey(column.ColumnName))
                        {
                            continue;
                        }

                        DataColumn newcolumn = dt.Columns.Add("_" + column.ColumnName, Type.GetType("System.String"));

                        Rpt_DataSetFields        field      = dicTreeColumnList[column.ColumnName];
                        Dictionary <int, string> cachevalue = new Dictionary <int, string>();

                        foreach (DataRow row in dt.Rows)
                        {
                            int value = 0;
                            if (int.TryParse(row[column].ToString(), out value))
                            {
                                if (cachevalue.ContainsKey(value))
                                {
                                    row[newcolumn] = cachevalue[value];
                                }
                                else
                                {
                                    if (field.TreeLevel == 100)
                                    {
                                        //显示全路径
                                        row[newcolumn] = TreeTableBLL.GetFullPathName(new UD_ModelFieldsBLL(field.FieldID, true).Model.RelationTableName, value);
                                    }
                                    else
                                    {
                                        //显示父级
                                        if (field.DisplayMode == 1)
                                        {
                                            row[newcolumn] = TreeTableBLL.GetSuperIDByLevel(new UD_ModelFieldsBLL(field.FieldID, true).Model.RelationTableName, value, field.TreeLevel).ToString();
                                        }
                                        else
                                        {
                                            row[newcolumn] = TreeTableBLL.GetSuperNameByLevel(new UD_ModelFieldsBLL(field.FieldID, true).Model.RelationTableName, value, field.TreeLevel);
                                        }
                                    }
                                    cachevalue.Add(value, row[newcolumn].ToString());
                                }
                            }
                        }
                        int order = column.Ordinal;
                        dt.Columns.Remove(column);
                        newcolumn.SetOrdinal(order);
                        newcolumn.ColumnName = newcolumn.ColumnName.Substring(1);
                    }
                    #endregion

                    break;

                default:
                    break;
                }

                if (_m.CommandType == 1 || _m.CommandType == 2)
                {
                    #region 加入计算列字段
                    IList <Rpt_DataSetFields> computefields = this.GetFields().Where(p => p.IsComputeField == "Y").ToList();
                    foreach (Rpt_DataSetFields field in computefields)
                    {
                        Type ColumnType;
                        switch (field.DataType)
                        {
                        case 1:         //整型(int)
                            ColumnType = Type.GetType("System.Int32");
                            break;

                        case 2:         //小数(decimal)
                            ColumnType = Type.GetType("System.Decimal");
                            break;

                        case 3:         //字符串(varchar)
                        case 6:         //字符串(nvarchar)
                            ColumnType = Type.GetType("System.String");
                            break;

                        case 4:         //日期(datetime)
                            ColumnType = Type.GetType("System.DateTime");
                            break;

                        case 5:         //GUID(uniqueidentifier)
                            ColumnType = Type.GetType("System.Guid");
                            break;

                        default:
                            ColumnType = Type.GetType("System.Decimal");
                            break;
                        }
                        try
                        {
                            dt.Columns.Add(field.FieldName, ColumnType, field.Expression);
                        }
                        catch { }
                    }
                    #endregion
                }

                if (dt != null && dt.Rows.Count < 200000)    //只对20万行以下的数据表进行缓存
                {
                    try
                    {
                        Rpt_DataSet_DataCacheBLL.SaveDataSetCache(_m.ID, ParamValue, dt);
                        CacheTime = DateTime.Now;
                    }
                    catch { System.GC.Collect(); }
                }
            }

            return(dt);
        }