Пример #1
0
    protected void tr_OfficialCity_Selected(object sender, MCSControls.MCSWebControls.SelectedEventArgs e)
    {
        cbl_OfficialList.Items.Clear();
        DataTable dt = TreeTableBLL.GetAllChildByNodes("MCS_SYS.dbo.Addr_OfficialCity", "ID", "SuperID", tr_OfficialCity.SelectValue);

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            Addr_OfficialCityBLL city = new Addr_OfficialCityBLL((int)dt.Rows[i]["ID"]);
            if (city.Model.Level == 3)
            {
                string   fullname = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", city.Model.ID);
                ListItem item     = new ListItem(fullname, city.Model.ID.ToString());

                IList <Addr_OfficialCityInOrganizeCity> organizecitys = Addr_OfficialCityInOrganizeCityBLL.GetModelList("OfficialCity=" + city.Model.ID.ToString());
                if (organizecitys.Count > 0)
                {
                    Addr_OrganizeCity organizecity = new Addr_OrganizeCityBLL(organizecitys[0].OrganizeCity).Model;
                    if (organizecity != null)
                    {
                        item.Text += "; 已归属于片区:【" + organizecity.Name + "】";
                    }
                    item.Enabled = false;
                }

                cbl_OfficialList.Items.Add(item);
            }
        }
    }
    private void BindData()
    {
        int id = (int)ViewState["ID"];

        ORD_OrderApply apply = new ORD_OrderApplyBLL(id).Model;

        if (apply == null)
        {
            Response.Redirect("FeeApplyList.aspx");
        }



        pn_OrderApply.BindData(apply);
        ViewState["Type"] = apply.Type;

        int month = new AC_AccountMonthBLL(apply.AccountMonth).Model.Month;

        ORD_OrderLimitFactorBLL limitbll = new ORD_OrderLimitFactorBLL();

        ViewState["Limit"] = limitbll.GetLimitInfo(apply.AccountMonth, apply.Client);

        #region 绑定当前申请单的管理片区
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");
        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", apply.OrganizeCity);
        #endregion

        BindGrid();
    }
    private void BindGrid()
    {
        lbl_message.Text = "费用报销审批汇总表";
        int id = (int)ViewState["ID"];

        FNA_FeeWriteOffBLL bll = new FNA_FeeWriteOffBLL(id);

        ViewState["Details"] = bll.Items.OrderBy(p => p.Client).ThenBy(p => p.AccountTitle).ThenBy(p => p.BeginMonth).ToList();

        FNA_FeeWriteOff writeoff = bll.Model;

        if (writeoff == null)
        {
            Response.Redirect("FeeWriteOffList.aspx");
        }

        BindGridPrint();
        string type = "";

        if (writeoff["InvoiceClassAB"] != "")
        {
            type = DictionaryBLL.GetDicCollections("FNA_InvoiceClassAB")[writeoff["InvoiceClassAB"]].Name;
        }
        // type = DictionaryBLL.Dictionary_Data_GetAlllList("TableName='FNA_InvoiceClassAB' AND Code='" + writeoff["InvoiceClassAB"] + "'")[0].Name;
        if (type == "")
        {
            type = "抵款";
        }
        span_sheetcode.InnerText    = writeoff.SheetCode;
        span_accountmonth.InnerText = new AC_AccountMonthBLL(writeoff.AccountMonth).Model.Name;
        if (bll.Model["InsteadPayStaff"] != "" && bll.Model["InsteadPayStaff"] != "0")
        {
            p_ddtype.InnerText    = "员工";
            span_client.InnerText = new Org_StaffBLL(int.Parse(bll.Model["InsteadPayStaff"])).Model.RealName;
        }
        else
        {
            span_client.InnerText = new CM_ClientBLL(writeoff.InsteadPayClient).Model.FullName;
        }
        int city5 = TreeTableBLL.GetSuperIDByLevel("MCS_SYS.dbo.Addr_OrganizeCity", writeoff.OrganizeCity, 5);

        span_orgnizecity.InnerText = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "Name", "SuperID", 1, city5 > 0 ? city5 : writeoff.OrganizeCity);
        span_type.InnerText        = type;
        span1.InnerText            = span2.InnerText = "1";

        //求费用核消金额合计
        decimal _totalcost = 0;

        foreach (FNA_FeeWriteOffDetail _detail in bll.Items)
        {
            _totalcost += _detail.WriteOffCost + _detail.AdjustCost;
        }

        lab_SubTotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(_totalcost.ToString());
        lab_SubTotalCost.Text   = _totalcost.ToString("#,##0.00");
        lab_SubTotalCost.Text   = lab_SubTotalCost.Text;
        lab_SubTotalCost.Text   = lab_SubTotalCost.Text;
    }
        /// <summary>
        /// 获取指定城市的全名
        /// </summary>
        /// <param name="AuthKey">匿名用户登录后的认证码</param>
        /// <param name="CityID"></param>
        /// <returns></returns>

        public static string GetCityFullName(UserInfo User, int CityID)
        {
            LogWriter.WriteLog("OfficialCityService.GetCityFullName:UserName="******",CityID=" + CityID.ToString());

            if (CityID <= 1)
            {
                return("中国");
            }

            return(TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", CityID).Replace("->", " "));
        }
    protected void tr_OrganizeCity_Selected(object sender, SelectedEventArgs e)
    {
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");

        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", e.CurSelectIndex);

        Label lb_SheetCode = (Label)pn_OrderApply.FindControl("ORD_OrderApply_SheetCode");

        lb_SheetCode.Text = ORD_OrderApplyBLL.GenerateSheetCode(e.CurSelectIndex, AC_AccountMonthBLL.GetCurrentMonth());

        MCSSelectControl select_Client = (MCSSelectControl)pn_OrderApply.FindControl("ORD_OrderApply_Client");

        select_Client.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCity=" + e.CurSelectIndex;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //初始化当前目录ID
            ViewState["FolderID"] = Request.QueryString["FolderID"] != null ? Request.QueryString["FolderID"].ToString() : "76";
            //上层目录
            Rpt_FolderBLL fbll = new Rpt_FolderBLL(int.Parse((string)ViewState["FolderID"]));
            superid = fbll.Model.SuperID != 0 ? fbll.Model.SuperID : 1;
            //当前目录路径
            //pathname = TreeTableBLL.GetFullPathName("MCS_Reports.dbo.Rpt_Folder", "ID", "Name", "SuperID", 0, int.Parse((string)ViewState["FolderID"]));
            pathname = TreeTableBLL.GetFullPathName("MCS_Reports.dbo.Rpt_Folder", int.Parse((string)ViewState["FolderID"]));

            BindData();
        }
    }
Пример #7
0
    private void BindData()
    {
        FNA_FeeWriteOffDetail m = new FNA_FeeWriteOffBLL().GetDetailModel((int)ViewState["ID"]);

        lb_AccountTitle.Text = TreeTableBLL.GetFullPathName("MCS_Pub.dbo.AC_AccountTitle", m.AccountTitle);
        lb_ApplyCost.Text    = m.ApplyCost.ToString("0.###");
        lb_WriteOffCost.Text = m.WriteOffCost.ToString("0.###");
        tbx_ApproveCost.Text = (m.WriteOffCost + m.AdjustCost).ToString("0.###");

        rbl_AdjustMode.SelectedValue = m.AdjustMode.ToString();

        try
        {
            if (new FNA_FeeWriteOffBLL(m.WriteOffID).Model["HasFeeApply"] == "N")
            {
                rbl_AdjustMode.Items.FindByValue("1").Enabled  = false;       //无申请直接核销的单子,不可选择“退回重新再核销”
                rbl_AdjustMode.Items.FindByValue("2").Selected = true;
            }
        }
        catch { }
    }
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int level        = int.Parse(ddl_Level.SelectedValue);
        int feetype      = int.Parse(ddl_FeeType.SelectedValue);
        int state        = int.Parse(ddl_State.SelectedValue);

        if (MCSTabControl1.SelectedIndex == 0)
        {
            #region 显示汇总单数据源
            Dictionary_Data dicFeeType = null;
            if (feetype > 0)
            {
                dicFeeType = DictionaryBLL.GetDicCollections("FNA_FeeType")[feetype.ToString()];
            }
            #region 额外条件
            string condition = "";
            //费用代垫客户
            if (select_Client.SelectValue != "")
            {
                condition += " AND FNA_FeeWriteOff.InsteadPayClient=" + select_Client.SelectValue;
            }

            //费用代垫员工
            if (Select_InsteadPayStaff.SelectValue != "")
            {
                condition += " AND MCS_SYS.dbo.UF_Spilt2('MCS_FNA.dbo.FNA_FeeWriteOff',FNA_FeeWriteOff.ExtPropertys,'InsteadPayStaff')=" + Select_InsteadPayStaff.SelectValue;
            }

            //核销申请人
            if (Select_InsertStaff.SelectValue != "")
            {
                condition += " AND FNA_FeeWriteOff.InsertStaff=" + Select_InsertStaff.SelectValue;
            }
            #endregion
            DataTable dtSummary = FNA_FeeWriteOffBLL.GetSummaryTotal(month, organizecity, level, feetype, state, int.Parse(Session["UserID"].ToString()), condition);
            if (dtSummary.Rows.Count == 0)
            {
                gv_List.DataBind();
                return;
            }

            #region 矩阵化数据表,扩展表数据列
            dtSummary.Columns.Add(new DataColumn("ID", Type.GetType("System.Int32")));
            if (level < 10)
            {
                foreach (DataRow row in dtSummary.Rows)
                {
                    row["ID"] = row["OrganizeCity"];
                }
                dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称" },
                                               new string[] { "FeeTypeName", "AccountTitleName" }, "WriteOffCost", true, true);
            }
            else
            {
                if (level == 10)
                {
                    //按经销商查看
                    #region 将经销商的所属管理片区赋至管理片区列
                    Dictionary <int, string> dicFullOrganizeCityName = new Dictionary <int, string>();
                    foreach (DataRow row in dtSummary.Rows)
                    {
                        row["ID"]    = row["经销商ID"] == DBNull.Value ? 0 : row["经销商ID"];
                        row["经销商名称"] = row["经销商名称"] == DBNull.Value ? "无" : row["经销商名称"];

                        if ((int)row["ID"] > 0)
                        {
                            CM_Client c = new CM_ClientBLL((int)row["ID"]).Model;
                            if (c != null)
                            {
                                if (!dicFullOrganizeCityName.ContainsKey(c.OrganizeCity))
                                {
                                    dicFullOrganizeCityName.Add(c.OrganizeCity, TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", c.OrganizeCity));
                                }
                                row["管理片区名称"] = dicFullOrganizeCityName[c.OrganizeCity];
                            }
                        }
                    }
                    #endregion

                    dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称", "经销商名称" },
                                                   new string[] { "FeeTypeName", "AccountTitleName" }, "WriteOffCost", true, true);
                }
                else if (level == 20)
                {
                    //按门店查看
                    #region 将门店的所属管理片区赋至管理片区列
                    Dictionary <int, string> dicFullOrganizeCityName = new Dictionary <int, string>();
                    foreach (DataRow row in dtSummary.Rows)
                    {
                        row["ID"]   = row["客户ID"] == DBNull.Value ? 0 : row["客户ID"];
                        row["客户名称"] = row["客户名称"] == DBNull.Value ? "无" : row["客户名称"];

                        if ((int)row["ID"] > 0)
                        {
                            CM_Client c = new CM_ClientBLL((int)row["ID"]).Model;
                            if (c != null)
                            {
                                if (!dicFullOrganizeCityName.ContainsKey(c.OrganizeCity))
                                {
                                    dicFullOrganizeCityName.Add(c.OrganizeCity, TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", c.OrganizeCity));
                                }
                                row["管理片区名称"] = dicFullOrganizeCityName[c.OrganizeCity];
                            }
                        }
                    }
                    #endregion

                    dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称", "客户名称" },
                                                   new string[] { "FeeTypeName", "AccountTitleName" }, "WriteOffCost", true, true);
                }
            }
            dtSummary = MatrixTable.ColumnSummaryTotal(dtSummary, new int[] { 1 }, new string[] { "WriteOffCost" });
            #endregion

            #region 暂不计算分析数据
            //dtSummary.Columns["合计"].ColumnName = "费用合计";
            //dtSummary.Columns.Add("预计销量", Type.GetType("System.Decimal"));

            //if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10)
            //{
            //    dtSummary.Columns.Add("预算总额", Type.GetType("System.Decimal"));
            //    dtSummary.Columns.Add("其中扩增额", Type.GetType("System.Decimal"));
            //    dtSummary.Columns.Add("预算余额", Type.GetType("System.Decimal"));
            //}

            //if (dicFeeType != null && dicFeeType.Description == "FeeRateControl")
            //    dtSummary.Columns.Add("上月余额", Type.GetType("System.Decimal"));

            //dtSummary.Columns.Add("费点", Type.GetType("System.String"));


            //decimal sumTotalVolume = 0, sumTotalBudget = 0, sumExtBudget = 0, sumPreMonthBudgetBalance = 0, sumUsableAmount = 0;
            //foreach (DataRow row in dtSummary.Rows)
            //{
            //    int id = 0;

            //    if (int.TryParse(row[0].ToString(), out id) && id > 0)
            //    {
            //        bool includechild = true;
            //        if (level < 10 && new Addr_OrganizeCityBLL(id).Model.Level < level) includechild = false;

            //        #region 计算费点
            //        if (level < 10)
            //            row["预计销量"] = SVM_SalesForcastBLL.GetTotalVolume(month, id, includechild);
            //        else if (level == 10 || level == 20)
            //            row["预计销量"] = SVM_SalesForcastBLL.GetTotalVolumeByClient(month, id);

            //        sumTotalVolume += (decimal)row["预计销量"];

            //        if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10)
            //        {
            //            row["预算总额"] = (FNA_BudgetBLL.GetSumBudgetAmount(month, id, feetype, includechild) + FNA_BudgetBLL.GetSumBudgetAmount(month, id, 0, includechild));
            //            sumTotalBudget += (decimal)row["预算总额"];

            //            row["其中扩增额"] = (FNA_BudgetExtraApplyBLL.GetExtraAmount(month, id, feetype, includechild) + FNA_BudgetExtraApplyBLL.GetExtraAmount(month, id, 0, includechild));
            //            sumExtBudget += (decimal)row["其中扩增额"];

            //            row["预算余额"] = (FNA_BudgetBLL.GetUsableAmount(month, id, feetype, includechild) + FNA_BudgetBLL.GetUsableAmount(month, id, 0, includechild));
            //            sumUsableAmount += (decimal)row["预算余额"];
            //        }

            //        if (dicFeeType != null && dicFeeType.Description == "FeeRateControl" && level < 10)
            //        {
            //            row["上月余额"] = FNA_BudgetBLL.GetUsableAmount(month - 1, id, feetype, includechild);
            //            sumPreMonthBudgetBalance += (decimal)row["上月余额"];

            //            if ((decimal)row["预计销量"] != 0)
            //                row["费点"] = (((decimal)row["费用合计"] - (decimal)row["上月余额"]) / (decimal)row["预计销量"]).ToString("0.00%");
            //        }
            //        else if ((decimal)row["预计销量"] != 0)
            //            row["费点"] = ((decimal)row["费用合计"] / (decimal)row["预计销量"]).ToString("0.00%");
            //        #endregion
            //    }

            //    #region 求合计行
            //    if (id == 0)
            //    {
            //        row["预计销量"] = sumTotalVolume.ToString("0.00");

            //        #region 预算总额及余额
            //        if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10)
            //        {
            //            row["预算总额"] = sumTotalBudget.ToString("0.00");
            //            row["其中扩增额"] = sumExtBudget.ToString("0.00");
            //            row["预算余额"] = sumUsableAmount.ToString("0.00");
            //        }
            //        #endregion

            //        #region 费点
            //        if (sumTotalVolume != 0)
            //        {
            //            if (dicFeeType != null && dicFeeType.Description == "FeeRateControl" && level < 10)
            //            {
            //                row["上月余额"] = sumPreMonthBudgetBalance;
            //                row["费点"] = (((decimal)row["费用合计"] - sumPreMonthBudgetBalance) / sumTotalVolume).ToString("0.##%");
            //            }
            //            else
            //                row["费点"] = ((decimal)row["费用合计"] / sumTotalVolume).ToString("0.##%");
            //        }
            //        #endregion
            //    }
            //    #endregion

            //}
            #endregion

            #endregion

            gv_List.DataSource = dtSummary;
            gv_List.DataBind();

            if (dtSummary.Columns.Count >= 24)
            {
                gv_List.Width = new Unit(dtSummary.Columns.Count * 55);
            }
            else
            {
                gv_List.Width = new Unit(100, UnitType.Percentage);
            }

            MatrixTable.GridViewMatric(gv_List);

            if (level == 20)
            {
                //按终端门店显示时,将上下行相同管理片区合并
                MatrixTable.GridViewMergSampeValueRow(gv_List, 0);
                MatrixTable.GridViewMergSampeValueRow(gv_List, 1);
            }
            #region 是否可以批量审批
            if (state != 1 || level >= 10)
            {
                gv_List.Columns[0].ItemStyle.Width = new Unit(1);
                foreach (GridViewRow row in gv_List.Rows)
                {
                    row.FindControl("bt_Approved").Visible   = false;
                    row.FindControl("bt_UnApproved").Visible = false;
                }
            }
            else
            {
                gv_List.Columns[0].ItemStyle.Width = new Unit(68);
            }
            #endregion
        }
        else
        {
            string condition = "1=1";

            #region 组织明细记录的查询条件
            //管理片区及所有下属管理片区
            if (tr_OrganizeCity.SelectValue != "1")
            {
                Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue));
                string orgcitys = orgcity.GetAllChildNodeIDs();
                if (orgcitys != "")
                {
                    orgcitys += ",";
                }
                orgcitys += tr_OrganizeCity.SelectValue;

                condition += " AND FNA_FeeWriteOff.OrganizeCity IN (" + orgcitys + ")";
            }

            //会计月条件
            condition += " AND FNA_FeeWriteOff.AccountMonth = " + ddl_Month.SelectedValue;

            int accounttile = 0;
            int.TryParse(tr_AccountTitle.SelectValue, out accounttile);
            decimal _cost = 0;
            decimal.TryParse(tbx_WriteOffCost.Text, out _cost);
            //费用类型
            if (ddl_FeeType.SelectedValue != "0" && !(accounttile > 1))
            {
                IList <AC_AccountTitleInFeeType> titles = AC_AccountTitleInFeeTypeBLL.GetModelList("FeeType=" + ddl_FeeType.SelectedValue);
                string ids = "";
                foreach (AC_AccountTitleInFeeType item in titles)
                {
                    ids += item.AccountTitle + ",";
                }
                if (ids.EndsWith(","))
                {
                    ids = ids.Substring(0, ids.Length - 1);
                }

                condition += " AND FNA_FeeWriteOff.ID IN (SELECT WriteOffID FROM MCS_FNA.dbo.FNA_FeeWriteOffDetail WHERE AccountTitle IN(" + ids + ") AND FNA_FeeWriteOffDetail.WriteOffID=FNA_FeeWriteOff.ID)";
            }

            //费用科目
            if (accounttile > 1)
            {
                DataTable dt  = TreeTableBLL.GetAllChildByNodes("MCS_PUB.dbo.AC_AccountTitle", "ID", "SuperID", accounttile.ToString());
                string    ids = "";
                foreach (DataRow dr in dt.Rows)
                {
                    ids += dr["ID"].ToString() + ",";
                }
                ids += accounttile.ToString();

                if (_cost == 0)
                {
                    condition += " AND FNA_FeeWriteOff.ID IN (SELECT WriteOffID FROM MCS_FNA.dbo.FNA_FeeWriteOffDetail WHERE AccountTitle IN(" + ids + ") AND FNA_FeeWriteOffDetail.WriteOffID=FNA_FeeWriteOff.ID)";
                }
                else
                {
                    condition += " AND FNA_FeeWriteOff.ID IN (SELECT WriteOffID FROM MCS_FNA.dbo.FNA_FeeWriteOffDetail WHERE AccountTitle IN(" + ids + ") AND (WriteOffCost+AdjustCost)" + ddl_WriteOffCostOP.SelectedValue + "  " + _cost.ToString() + " AND FNA_FeeWriteOffDetail.WriteOffID=FNA_FeeWriteOff.ID)";
                }
            }
            else if (_cost != 0)
            {   //核销金额判断
                condition += " AND FNA_FeeWriteOff.ID IN (SELECT WriteOffID FROM MCS_FNA.dbo.FNA_FeeWriteOffDetail WHERE (WriteOffCost+AdjustCost)" + ddl_WriteOffCostOP.SelectedValue + "  " + _cost.ToString() + " AND FNA_FeeWriteOffDetail.WriteOffID=FNA_FeeWriteOff.ID)";
            }

            //审批状态
            if (ddl_State.SelectedValue == "0")
            {
                condition += " AND FNA_FeeWriteOff.State IN (2,3) ";
            }
            else if (ddl_State.SelectedValue == "1")
            {
                condition +=
                    @" AND FNA_FeeWriteOff.State = 2 AND FNA_FeeWriteOff.ApproveTask IN 
(SELECT EWF_Task_Job.Task FROM  MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
    MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND
    EWF_Task_JobDecision.DecisionResult=1 and EWF_Task_Job.Status=3)";
            }
            else if (ddl_State.SelectedValue == "2")
            {
                condition += " AND FNA_FeeWriteOff.State = 3 ";
            }
            else if (ddl_State.SelectedValue == "3")
            {
                AC_AccountMonth m = new AC_AccountMonthBLL(month).Model;
                condition +=
                    @" AND FNA_FeeWriteOff.State IN (2,3) AND FNA_FeeWriteOff.ApproveTask IN 
(SELECT EWF_Task_Job.Task FROM  MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
	MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND
	EWF_Task_JobDecision.DecisionResult IN(2,5,6) AND 
	EWF_Task_JobDecision.DecisionTime BETWEEN DATEADD(month,-1,'"     + m.BeginDate.ToString("yyyy-MM-dd") + @"') AND 
		DATEADD(month,3,'"         + m.BeginDate.ToString("yyyy-MM-dd") + @"'))";
            }

            //费用代垫客户
            if (select_Client.SelectValue != "")
            {
                condition += " AND FNA_FeeWriteOff.InsteadPayClient=" + select_Client.SelectValue;
            }

            //费用代垫员工
            if (Select_InsteadPayStaff.SelectValue != "")
            {
                condition += " AND MCS_SYS.dbo.UF_Spilt2('MCS_FNA.dbo.FNA_FeeWriteOff',FNA_FeeWriteOff.ExtPropertys,'InsteadPayStaff')=" + Select_InsteadPayStaff.SelectValue;
            }

            //核销申请人
            if (Select_InsertStaff.SelectValue != "")
            {
                condition += " AND FNA_FeeWriteOff.InsertStaff=" + Select_InsertStaff.SelectValue;
            }
            #endregion

            gv_ListDetail.ConditionString = condition;
            gv_ListDetail.BindGrid();
        }
    }
    private DataTable LoadWorkingPlanDetail(int planid)
    {
        JN_WorkingPlanBLL bll = new JN_WorkingPlanBLL(planid);

        DataTable dt = GenareateDataTable(bll.Model.BeginDate, bll.Model.EndDate);

        #region 载入原工作计划
        foreach (JN_WorkingPlanDetail detail in bll.Items.OrderBy(p => p.WorkingClassify))
        {
            DataRow[] rows = dt.Select("WorkingClassify = " + detail.WorkingClassify.ToString() +
                                       " AND Description = '" + detail.Description + "' " +
                                       " AND RelateStaff = " + detail.RelateStaff.ToString() +
                                       " AND RelateClient = " + detail.RelateClient.ToString() +
                                       " AND OfficialCity = " + detail.OfficialCity.ToString());
            if (rows.Length > 0)
            {
                DateTime date = detail.BeginTime;
                while (date <= detail.EndTime)
                {
                    rows[0]["P" + date.ToString("MMdd")] = true;
                    date = date.AddDays(1);
                }
            }
            else
            {
                DataRow dr = dt.NewRow();

                dr["WorkingClassify"]     = detail.WorkingClassify;
                dr["WorkingClassifyName"] = DictionaryBLL.GetDicCollections("OA_WorkingClassify")[detail.WorkingClassify.ToString()].Name;
                dr["Description"]         = detail.Description;

                dr["RelateClient"] = detail.RelateClient;
                if (detail.RelateClient > 0)
                {
                    dr["RelateClientName"] = new CM_ClientBLL(detail.RelateClient).Model.FullName;
                }

                dr["RelateStaff"] = detail.RelateStaff;
                if (detail.RelateStaff > 0)
                {
                    dr["RelateStaffName"] = new Org_StaffBLL(detail.RelateStaff).Model.RealName;
                }

                dr["OfficialCity"] = detail.OfficialCity;
                if (detail.OfficialCity > 0)
                {
                    dr["OfficialCityName"] = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", detail.OfficialCity).Replace("->", " ");
                }

                DateTime date = detail.BeginTime;
                while (date <= detail.EndTime)
                {
                    dr["P" + date.ToString("MMdd")] = true;
                    date = date.AddDays(1);
                }

                if (detail["Cost1"] != "")
                {
                    dr["Cost1"] = decimal.Parse(detail["Cost1"]);
                }
                else
                {
                    dr["Cost1"] = 0;
                }

                if (detail["Cost2"] != "")
                {
                    dr["Cost2"] = decimal.Parse(detail["Cost2"]);
                }
                else
                {
                    dr["Cost2"] = 0;
                }

                dt.Rows.Add(dr);
            }
        }
        #endregion

        #region 加载数据库中已填报的日志
        string con = "Staff = " + bll.Model.Staff.ToString() +
                     " AND BeginTime BETWEEN '" + bll.Model.BeginDate.ToString("yyyy-MM-dd") + "' AND '" + bll.Model.EndDate.ToString("yyyy-MM-dd 23:59:59") + "' " +
                     " AND JournalType = 1";
        IList <JN_Journal> Journals = JN_JournalBLL.GetModelList(con);

        foreach (JN_Journal journal in Journals.OrderBy(p => p.WorkingClassify))
        {
            DataRow[] rows = dt.Select("WorkingClassify = " + journal.WorkingClassify.ToString() +
                                       " AND Description = '" + journal.Title + "' " +
                                       " AND RelateStaff = " + (journal.WorkingClassify == 2 ? journal.RelateStaff.ToString() : "0") +
                                       " AND RelateClient = " + (journal.WorkingClassify == 1 ? journal.RelateClient.ToString() : "0") +
                                       " AND OfficialCity = " + journal.OfficialCity.ToString());

            if (rows.Length == 0)
            {
                rows = dt.Select("WorkingClassify = " + journal.WorkingClassify.ToString() +
                                 " AND Description = '' " +
                                 " AND RelateStaff = " + (journal.WorkingClassify == 2 ? journal.RelateStaff.ToString() : "0") +
                                 " AND RelateClient = " + (journal.WorkingClassify == 1 ? journal.RelateClient.ToString() : "0") +
                                 " AND OfficialCity = " + journal.OfficialCity.ToString());
            }

            if (rows.Length > 0)
            {
                rows[0]["J" + journal.BeginTime.ToString("MMdd")]   = true;
                rows[0]["JID" + journal.BeginTime.ToString("MMdd")] = journal.ID;

                DateTime date = journal.BeginTime;
                while (date <= journal.EndTime)
                {
                    rows[0]["J" + date.ToString("MMdd")]   = true;
                    rows[0]["JID" + date.ToString("MMdd")] = journal.ID;
                    date = date.AddDays(1);
                }
            }
            else
            {
                #region 增加无计划的日志
                DataRow dr = dt.NewRow();

                dr["WorkingClassify"] = journal.WorkingClassify;
                if (journal.WorkingClassify > 0)
                {
                    dr["WorkingClassifyName"] = DictionaryBLL.GetDicCollections("OA_WorkingClassify")[journal.WorkingClassify.ToString()].Name;
                }
                dr["Description"] = journal.Title;

                dr["RelateClient"] = journal.RelateClient;
                if (journal.RelateClient > 0)
                {
                    dr["RelateClientName"] = new CM_ClientBLL(journal.RelateClient).Model.FullName;
                }

                dr["RelateStaff"] = journal.RelateStaff;
                if (journal.RelateStaff > 0)
                {
                    dr["RelateStaffName"] = new Org_StaffBLL(journal.RelateStaff).Model.RealName;
                }

                dr["OfficialCity"] = journal.OfficialCity;
                if (journal.OfficialCity > 0)
                {
                    dr["OfficialCityName"] = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", journal.OfficialCity).Replace("->", " ");
                }

                DateTime date = journal.BeginTime;
                while (date <= journal.EndTime)
                {
                    dr["J" + date.ToString("MMdd")]   = true;
                    dr["JID" + date.ToString("MMdd")] = journal.ID;
                    date = date.AddDays(1);
                }

                dt.Rows.Add(dr);
                #endregion
            }
        }
        #endregion
        return(dt);
    }
Пример #10
0
        /// <summary>
        /// Bind data to the control by special NameValueCollection
        /// </summary>
        public void BindData(NameValueCollection dataobjects)
        {
            foreach (object key in HTDataObjectControlInfo.Keys)
            {
                DataObjectControlInfo _dataobjectcontrolinfo = (DataObjectControlInfo)HTDataObjectControlInfo[key];
                EWF_Flow_DataObject   _dataobjct             = new EWF_Flow_DataObjectBLL(_dataobjectcontrolinfo.DataObjectID).Model;

                try
                {
                    switch (_dataobjectcontrolinfo.ControlType)
                    {
                    case 1:     //Label控件
                        if (_dataobjct.RelationType == 3)
                        {
                            ((Label)this.FindControl(_dataobjectcontrolinfo.ControlName)).Text = dataobjects[key.ToString()];
                        }
                        else
                        {
                            if (_dataobjct.RelationType == 2 && new UD_TableListBLL(_dataobjct.RelationTableName).Model.TreeFlag == "Y")
                            {
                                //关联到实体树形结构表时,显示全路径
                                int value = 0;
                                if (int.TryParse(dataobjects[key.ToString()], out value))
                                {
                                    ((Label)this.FindControl(_dataobjectcontrolinfo.ControlName)).Text = TreeTableBLL.GetFullPathName(_dataobjct.RelationTableName, value);
                                }
                            }
                            else
                            {
                                ((Label)this.FindControl(_dataobjectcontrolinfo.ControlName)).Text = GetRelateTextByValue(_dataobjct, dataobjects[key.ToString()]);
                            }
                        }
                        break;

                    case 2:
                    case 5:
                        if (_dataobjct.RelationType == 3)
                        {
                            ((TextBox)this.FindControl(_dataobjectcontrolinfo.ControlName)).Text = dataobjects[key.ToString()];
                        }
                        else
                        {
                            ((TextBox)this.FindControl(_dataobjectcontrolinfo.ControlName)).Text = GetRelateTextByValue(_dataobjct, dataobjects[key.ToString()]);
                        }
                        break;

                    case 3:
                        if (dataobjects[key.ToString()] != "")
                        {
                            ((DropDownList)this.FindControl(_dataobjectcontrolinfo.ControlName)).SelectedValue = dataobjects[key.ToString()];
                        }
                        break;

                    case 4:
                        if (dataobjects[key.ToString()] != "")
                        {
                            ((RadioButtonList)this.FindControl(_dataobjectcontrolinfo.ControlName)).SelectedValue = dataobjects[key.ToString()];
                        }
                        break;

                    case 6:     //带选择功能的控件
                        if (dataobjects[key.ToString()] != "")
                        {
                            ((MCSSelectControl)this.FindControl(_dataobjectcontrolinfo.ControlName)).SelectValue = dataobjects[key.ToString()];
                            ((MCSSelectControl)this.FindControl(_dataobjectcontrolinfo.ControlName)).SelectText  = GetRelateTextByValue(_dataobjct, dataobjects[key.ToString()]);
                        }
                        break;

                    case 7:
                        if (dataobjects[key.ToString()] != "")
                        {
                            ((MCSTreeControl)this.FindControl(_dataobjectcontrolinfo.ControlName)).SelectValue = dataobjects[key.ToString()];
                        }
                        break;
                    }
                }
                catch { }
            }
        }
Пример #11
0
    private void BindData()
    {
        int id = (int)ViewState["ID"];
        ORD_OrderDelivery m = new ORD_OrderDeliveryBLL(id).Model;

        if (m == null)
        {
            Response.Redirect("OrderDeliveryList.aspx");
        }

        pn_OrderDelivery.BindData(m);

        #region 绑定当前申请单的管理片区
        Label lb_OrganizeCity = (Label)pn_OrderDelivery.FindControl("ORD_OrderDelivery_OrganizeCity");
        lb_OrganizeCity.Text        = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", m.OrganizeCity);
        tr_OrganizeCity.SelectValue = m.OrganizeCity.ToString();
        tr_OrganizeCity.Enabled     = false;
        select_Client.PageUrl       = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCity=" + tr_OrganizeCity.SelectValue;
        #endregion

        #region 根据状态控制页面显示
        switch (m.State)
        {
        case 1:     //未发货
            if (m.ApproveFlag == 2)
            {       //未审核
                BindOrderApplyCanDelivery();
                pn_OrderDelivery.SetPanelVisible("Panel_LGS_OrderDeliveryDetail_02", false);
                bt_ConfirmDelivery.Visible = false;
                gv_OrderList.Columns[gv_OrderList.Columns.Count - 1].Visible = true;
            }
            else
            {
                bt_Approve.Visible      = false;
                tr_FeeApplyList.Visible = false;
                bt_Save.Visible         = false;
                bt_Delete.Visible       = false;
            }
            bt_ConfirmSignIn.Visible = false;
            bNoDelivery = true;
            pn_OrderDelivery.SetPanelVisible("Panel_LGS_OrderDeliveryDetail_03", false);
            break;

        case 2:         //已发货
            bt_Save.Visible            = false;
            bt_Delete.Visible          = false;
            bt_Approve.Visible         = false;
            bt_ConfirmDelivery.Visible = false;
            tr_FeeApplyList.Visible    = false;
            bNoSignIn = true;
            gv_OrderList.Columns[gv_OrderList.Columns.Count - 4].Visible = true;
            gv_OrderList.Columns[gv_OrderList.Columns.Count - 3].Visible = true;
            gv_OrderList.Columns[gv_OrderList.Columns.Count - 2].Visible = true;
            pn_OrderDelivery.SetPanelEnable("Panel_LGS_OrderDeliveryDetail_02", false);
            break;

        case 3:         //已签收
            bt_Save.Visible            = false;
            bt_Delete.Visible          = false;
            bt_Approve.Visible         = false;
            bt_ConfirmDelivery.Visible = false;
            bt_ConfirmSignIn.Visible   = false;
            tr_FeeApplyList.Visible    = false;
            bNoSignIn = false;
            gv_OrderList.Columns[gv_OrderList.Columns.Count - 4].Visible = true;
            gv_OrderList.Columns[gv_OrderList.Columns.Count - 3].Visible = true;
            gv_OrderList.Columns[gv_OrderList.Columns.Count - 2].Visible = true;
            pn_OrderDelivery.SetPanelEnable("Panel_LGS_OrderDeliveryDetail_02", false);
            pn_OrderDelivery.SetPanelEnable("Panel_LGS_OrderDeliveryDetail_03", false);
            break;

        default:
            break;
        }
        #endregion

        BindGrid();
    }
Пример #12
0
        /// <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);
        }
Пример #13
0
    private void BindData()
    {
        int id = (int)ViewState["ID"];

        ORD_OrderApply apply = new ORD_OrderApplyBLL(id).Model;

        if (apply == null)
        {
            Response.Redirect("OrderApplyList.aspx");
        }

        if (apply["ProductType"] != "1")
        {
            priceEnable = true;
        }

        pn_OrderApply.BindData(apply);
        ViewState["Type"] = apply.Type;

        int month = new AC_AccountMonthBLL(apply.AccountMonth).Model.Month;

        ORD_OrderLimitFactorBLL limitbll = new ORD_OrderLimitFactorBLL();

        ViewState["Limit"] = limitbll.GetLimitInfo(apply.AccountMonth, apply.Client);

        #region 绑定当前申请单的管理片区
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");
        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", apply.OrganizeCity);
        #endregion

        #region 根据审批状态控制页面

        if (apply.State != 1 && apply.State != 8)
        {
            //提交 状态

            pn_OrderApply.SetControlsEnable(false);
            gv_ProductList.Columns[0].Visible = false;                                //选择 列
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 1].Visible = false; //删除 列
            bt_Save.Visible   = false;
            bt_Submit.Visible = false;
            bt_Delete.Visible = false;
            //可见调整数量及原因
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 4].Visible = true;      //调整原因
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 5].Visible = true;      //调整金额
            bt_SaveAdjust.Visible = false;
        }

        if (apply.State == 2)
        {
            bt_SaveAdjust.Visible = false;

            ///已提交状态,审批过程中,可以作申请数量调整
            if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
            {
                bt_SaveAdjust.Visible = true;
            }
        }

        if (apply.State >= 3)
        {
            bt_SaveAdjust.Visible = false;

            //审批通过
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 3].Visible = true;      //已发放数量
        }
        #endregion

        BindGrid();
    }
Пример #14
0
 public static string GetFullCategoryName(int ID)
 {
     return(TreeTableBLL.GetFullPathName("MCS_PUB.dbo.PDT_Category", ID));
 }
    protected void bt_AddDetail_Click(object sender, EventArgs e)
    {
        SaveDataTable();

        if (ddl_WorkingClassify.SelectedValue == "0")
        {
            MessageBox.Show(this, "请先选择要增加的工作类型!");
            return;
        }
        else if (ddl_WorkingClassify.SelectedValue == "1" && string.IsNullOrEmpty(select_RelateClient.SelectValue))
        {
            MessageBox.Show(this, "请先选择你要拜访的客户!");
            return;
        }
        else if (ddl_WorkingClassify.SelectedValue == "2" && string.IsNullOrEmpty(select_RelateStaff.SelectValue))
        {
            MessageBox.Show(this, "请先选择你要协同拜访的员工!");
            return;
        }

        DateTime begindate = DateTime.Parse(tbx_Begin.Text);
        DateTime enddate   = DateTime.Parse(tbx_End.Text);

        if (begindate < (DateTime)ViewState["BeginDate"])
        {
            MessageBox.Show(this, "本工作项的开始日期不能小于整个计划开始日期!");
            return;
        }
        if (enddate > (DateTime)ViewState["EndDate"])
        {
            MessageBox.Show(this, "本工作项的截止日期不能大于整个计划截止日期!");
            return;
        }
        if (ViewState["WorkingPlanData"] != null)
        {
            DataTable dt = (DataTable)ViewState["WorkingPlanData"];

            DataRow dr = dt.NewRow();
            dr["WorkingClassify"]     = int.Parse(ddl_WorkingClassify.SelectedValue);
            dr["WorkingClassifyName"] = ddl_WorkingClassify.SelectedItem.Text;

            switch (ddl_WorkingClassify.SelectedValue)
            {
            case "1":
                #region 增加客户拜访计划
            {
                if (select_RelateClient.SelectValue == "" || select_RelateClient.SelectValue == "0")
                {
                    MessageBox.Show(this, "请选择要拜访的客户!");
                    return;
                }
                if (dt.Select("WorkingClassify=1 AND RelateClient=" + select_RelateClient.SelectValue).Length > 0)
                {
                    MessageBox.Show(this, "对不起,列表中已有相同的行了,不能重复添加!");
                    return;
                }

                dr["RelateClient"]     = int.Parse(select_RelateClient.SelectValue);
                dr["RelateClientName"] = select_RelateClient.SelectText;
                dr["RelateStaff"]      = 0;
            }
                #endregion
                break;

            case "2":
                #region 循环增加协同拜访员工计划
            {
                int staffid = 0;
                if (!int.TryParse(select_RelateStaff.SelectValue, out staffid))
                {
                    return;
                }
                if (staffid == int.Parse(select_PlanStaff.SelectValue))
                {
                    return;
                }
                Org_Staff staff = new Org_StaffBLL(staffid).Model;
                if (staff == null)
                {
                    return;
                }

                if (dt.Select("WorkingClassify=2 AND RelateStaff=" + staffid.ToString()).Length > 0)
                {
                    MessageBox.Show(this, "对不起,列表中已有相同的行了,不能重复添加!");
                    return;
                }
                ;


                dr["RelateStaff"]     = staffid;
                dr["RelateStaffName"] = staff.RealName;
                dr["RelateClient"]    = 0;

                if (staff.OfficialCity > 1)
                {
                    dr["OfficialCity"]     = staff.OfficialCity;
                    dr["OfficialCityName"] = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", staff.OfficialCity).Replace("->", " ");;
                }
                dt.Rows.Add(dr);
            }
                #endregion
                break;

            default:
                #region 增加其他工作计划
            {
                if (dt.Select("WorkingClassify=" + ddl_WorkingClassify.SelectedValue +
                              " AND Description='" + tbx_Description.Text +
                              "' AND OfficialCity=" + tr_OfficailCity.SelectValue).Length > 0)
                {
                    MessageBox.Show(this, "对不起,列表中已有相同的行了,不能重复添加!");
                    return;
                }

                dr["RelateStaff"]  = 0;
                dr["RelateClient"] = 0;
                dr["Description"]  = tbx_Description.Text;
            }
                #endregion
                break;
            }

            if (!string.IsNullOrEmpty(tr_OfficailCity.SelectValue) && tr_OfficailCity.SelectValue != "0")
            {
                dr["OfficialCity"]     = int.Parse(tr_OfficailCity.SelectValue);
                dr["OfficialCityName"] = new Addr_OfficialCityBLL(int.Parse(tr_OfficailCity.SelectValue)).Model.Name;
            }
            if (tbx_Cost1.Text != "")
            {
                dr["Cost1"] = decimal.Parse(tbx_Cost1.Text);
            }
            else
            {
                dr["Cost1"] = 0;
            }

            if (tbx_Cost2.Text != "")
            {
                dr["Cost2"] = decimal.Parse(tbx_Cost2.Text);
            }
            else
            {
                dr["Cost2"] = 0;
            }

            DateTime day = begindate;
            while (day <= enddate)
            {
                dr["P" + day.ToString("MMdd")] = true;
                day = day.AddDays(1);
            }

            dt.Rows.Add(dr);
            #region 清空已录入的工作计划数据,以便下次再录
            select_RelateStaff.SelectValue  = "";
            select_RelateStaff.SelectText   = "";
            select_RelateClient.SelectValue = "";
            select_RelateClient.SelectText  = "";
            if (ViewState["StaffOfficialCity"] != null)
            {
                tr_OfficailCity.SelectValue = ViewState["StaffOfficialCity"].ToString();
            }
            #endregion

            cb_DisplayCheckedOnly.Checked = false;
            BindGrid();
        }
    }
Пример #16
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #17
0
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        if (ViewState["Staff"] != null && (int)ViewState["Staff"] > 0)
        {
            e.Cell.HorizontalAlign = HorizontalAlign.Left;

            if (e.Day.Date <= DateTime.Today && MCSTabControl1.SelectedIndex == 0)
            {
                ImageButton ibt = new ImageButton();
                ibt.ImageUrl      = "~/Images/gif/gif-0489.gif";
                ibt.BorderWidth   = new Unit(0);
                ibt.ToolTip       = "新增工作日志";
                ibt.OnClientClick = "javascript:NewJournal('" + e.Day.Date.DayOfYear.ToString() + "')";
                ibt.Click        += new ImageClickEventHandler(ibt_Click);
                e.Cell.Controls.Add(ibt);
            }

            #region 获取该员工当天工作日志
            if (cbx_Journal.Checked)
            {
                IList <JN_Journal> journallists = JN_JournalBLL.GetModelList("'" + e.Day.Date.ToString("yyyy-MM-dd") + "' BETWEEN Convert(varchar(10),BeginTime,120) And EndTime AND Staff=" + ViewState["Staff"].ToString());
                if (journallists.Count > 0)
                {
                    BulletedList bt = new BulletedList();
                    foreach (JN_Journal j in journallists)
                    {
                        ListItem item = new ListItem();
                        item.Text = "";
                        if (j.JournalType == 1)
                        {
                            //日报
                            if (j.BeginTime.Hour != 0 && j.EndTime.Hour != 0)
                            {
                                item.Text += j.BeginTime.ToString("HH:mm") + "~" + j.EndTime.ToString("HH:mm") + " ";
                            }
                            if (j.WorkingClassify != 0)
                            {
                                item.Text += DictionaryBLL.GetDicCollections("OA_WorkingClassify")[j.WorkingClassify.ToString()].Name + " ";
                                switch (j.WorkingClassify)
                                {
                                case 1:    //门店拜访
                                    if (j.RelateClient != 0)
                                    {
                                        //门店拜访
                                        CM_Client client = new CM_ClientBLL(j.RelateClient).Model;
                                        if (client != null)
                                        {
                                            item.Text += client.ShortName + " ";
                                        }

                                        if (j["VisitClientPurpose"] != "" && j["VisitClientPurpose"] != "0")
                                        {
                                            item.Text += DictionaryBLL.GetDicCollections("OA_JN_VisitClientPurpose")[j["VisitClientPurpose"]].Name + " ";
                                        }
                                    }
                                    break;

                                case 2:     //协同拜访
                                    if (j.RelateStaff != 0)
                                    {
                                        Org_Staff staff = new Org_StaffBLL(j.RelateStaff).Model;
                                        if (staff != null)
                                        {
                                            item.Text += staff.RealName;
                                        }
                                    }
                                    break;

                                default:
                                    item.Text += j.Title;
                                    break;
                                }
                            }
                            else
                            {
                                item.Text += j.Title;
                            }
                        }
                        else
                        {
                            //周报、月报
                            item.Text += DictionaryBLL.GetDicCollections("OA_JournalType")[j.JournalType.ToString()].Name + " ";
                            item.Text += j.Title;
                        }
                        item.Value = "javascript:OpenJournal(" + j.ID.ToString() + ")";
                        bt.Items.Add(item);
                    }
                    bt.DisplayMode    = BulletedListDisplayMode.HyperLink;
                    bt.BulletImageUrl = "~/Images/gif/gif-0162.gif";
                    bt.BulletStyle    = BulletStyle.CustomImage;
                    bt.CssClass       = "calaitem";
                    e.Cell.Controls.Add(bt);
                }
            }
            #endregion

            #region 获取访员工当天的工作计划
            if (cbx_Plan.Checked)
            {
                if (ViewState["PlanDetails"] == null || ((IList <JN_WorkingPlanDetail>)ViewState["PlanDetails"]).Where
                        (p => (p.BeginTime.Date <= e.Day.Date && p.EndTime.Date >= e.Day.Date)).Count() == 0)
                {
                    IList <JN_WorkingPlan> plans = JN_WorkingPlanBLL.GetModelList("'" + e.Day.Date.ToString("yyyy-MM-dd") +
                                                                                  "' BETWEEN BeginDate AND EndDate AND Staff=" + ViewState["Staff"].ToString());
                    if (plans.Count > 0)
                    {
                        IList <JN_WorkingPlanDetail> plandetails = new JN_WorkingPlanBLL(plans[0].ID).Items;
                        ViewState["PlanDetails"] = plandetails;
                    }
                    else
                    {
                        ViewState["PlanDetails"] = null;
                    }
                }

                if (ViewState["PlanDetails"] != null)
                {
                    IList <JN_WorkingPlanDetail> plandetails = (IList <JN_WorkingPlanDetail>)ViewState["PlanDetails"];

                    BulletedList bt = new BulletedList();

                    foreach (JN_WorkingPlanDetail plan in plandetails.Where(p => (p.BeginTime.Date <= e.Day.Date && p.EndTime.Date >= e.Day.Date)))
                    {
                        ListItem item = new ListItem();
                        item.Text = "";

                        if (plan.WorkingClassify == 0)
                        {
                            continue;
                        }
                        item.Text += DictionaryBLL.GetDicCollections("OA_WorkingClassify")[plan.WorkingClassify.ToString()].Name + " ";
                        switch (plan.WorkingClassify)
                        {
                        case 1:    //门店拜访
                            if (plan.RelateClient != 0)
                            {
                                //门店拜访
                                CM_Client client = new CM_ClientBLL(plan.RelateClient).Model;
                                if (client != null)
                                {
                                    item.Text += client.ShortName + " ";
                                }
                            }
                            break;

                        case 2:     //协同拜访
                            if (plan.RelateStaff != 0)
                            {
                                Org_Staff staff = new Org_StaffBLL(plan.RelateStaff).Model;
                                if (staff != null)
                                {
                                    item.Text += staff.RealName + " ";
                                }
                            }
                            break;

                        default:
                            item.Text += plan.Description + " ";
                            break;
                        }
                        if (plan.OfficialCity > 1)
                        {
                            item.Text += TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", plan.OfficialCity).Replace("->", "");
                        }
                        bt.Items.Add(item);
                    }
                    bt.DisplayMode    = BulletedListDisplayMode.Text;
                    bt.BulletImageUrl = "~/Images/gif/gif-0163.gif";
                    bt.BulletStyle    = BulletStyle.CustomImage;
                    bt.CssClass       = "calaitem";
                    e.Cell.Controls.Add(bt);
                }
            }
            #endregion
        }
    }
Пример #18
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 { }
                }
            }
        }