Ejemplo n.º 1
0
        private string Prefix(string key)
        {
            if (GridName.HasValue())
            {
                return(GridName + "-" + key);
            }

            return(key);
        }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            // No actions if processing is stopped
        }
        else
        {
            String defDir = GetDefaultGridDirectory();

            // If grid name is not set, find in default directory
            if (String.IsNullOrEmpty(GridName))
            {
                GridName = String.Format("{0}/{1}", defDir, "default.xml");
            }
            else if (!GridName.StartsWith("~"))
            {
                // If only grid name is specified (not path), append name to default directory
                GridName = String.Format("{0}/{1}", defDir, GridName);
            }

            // Check the configuration file
            String path = Server.MapPath(GridName);
            if (!File.Exists(path))
            {
                ShowError(String.Format(GetString("unigrid.noxmluifile"), path));
                return;
            }

            gridElem.GridName = GridName;

            if (!String.IsNullOrEmpty(ZeroRowsText))
            {
                gridElem.ZeroRowsText = ResHelper.LocalizeString(ZeroRowsText);
            }

            if (!String.IsNullOrEmpty(WhereCondition))
            {
                gridElem.WhereCondition = WhereCondition;
            }

            if (!String.IsNullOrEmpty(OrderBy))
            {
                gridElem.OrderBy = OrderBy;
            }
            // Default order by - use object's display name
            else if (mEmptyCurrentInfo != null)
            {
                // Sort by order column, if not defined, use display name
                gridElem.OrderBy = (mEmptyCurrentInfo.TypeInfo.OrderColumn == ObjectTypeInfo.COLUMN_NAME_UNKNOWN) ? mEmptyCurrentInfo.Generalized.DisplayNameColumn : mEmptyCurrentInfo.TypeInfo.OrderColumn;
            }

            // Set edit script or redirect
            gridElem.EditActionUrl = !String.IsNullOrEmpty(EditActionUrl) ? ResolveUrl(EditActionUrl) : GetEditUrl();
        }
    }
Ejemplo n.º 3
0
            protected virtual int ExportGrid(Worksheet ws, DataTable dtTemp, GridName gridName, int rowBeginIndex, string oswGrpText)
            {
                int rowIndex      = rowBeginIndex;
                int cp_max_seq_no = dtTemp.Rows[0]["cp_max_seq_no"].AsInt();
                int colStart1     = 0;
                int colStart2     = cp_max_seq_no + 1;
                int colStart3     = (cp_max_seq_no * 2) + 2;

                //2.4月總量/日均量--第一排表頭
                if (SumType == "D")
                {
                    //
                }
                else
                {
                    if (gridName == GridName.First)
                    {
                        ws.Cells[rowIndex, 0].Value = "月總量";
                    }
                    else
                    {
                        ws.Cells[rowIndex, 0].Value     = "日均量";
                        ws.Cells[rowIndex + 1, 0].Value = "代碼";
                        ws.Cells[rowIndex + 2, 0].Value = "名稱";
                    }
                }

                ws.Cells[rowIndex, colStart1 + 1].Value = oswGrpText + "交易量";
                ws.Cells[rowIndex, colStart2 + 1].Value = "一般交易時段交易量";
                ws.Cells[rowIndex, colStart3 + 1].Value = "延長交易時段交易量比重";

                ws.Cells[rowIndex + 2, colStart2].Value = "小計";
                ws.Cells[rowIndex + 2, colStart3].Value = "小計";
                ws.Cells[rowIndex + 2, colStart3 + cp_max_seq_no + 1].Value = "小計";

                //2.5月總量/日均量--第二排表頭
                rowIndex++;

                //ken,又一個特殊處理,當sql的order by am11_ymd , am11_kind_id , seq_no,要使用find必須單純sort,所以要儘量把seq_no弄成唯一
                //DataTable dtHeader = dtTemp.Clone();
                //for (int y = 0;y < cp_max_seq_no;y++) {
                //   dtHeader.Rows.Add(dtTemp.Rows[y]);
                //}
                //DataView dv = dtHeader.AsDataView();
                //dv.Sort = "seq_no";

                for (int k = 1; k <= cp_max_seq_no; k++)
                {
                    //int ll_found = dv.Find(k);
                    int ll_found = dtTemp.Rows.IndexOf(dtTemp.Select("seq_no = " + k).FirstOrDefault());
                    if (ll_found < 0)
                    {
                        continue;
                    }
                    string am11_kind_id = dtTemp.Rows[ll_found]["am11_kind_id"].AsString();
                    string apdk_name    = dtTemp.Rows[ll_found]["apdk_name"].AsString();

                    ws.Cells[rowIndex + 0, k + colStart1].Value = am11_kind_id;
                    ws.Cells[rowIndex + 1, k + colStart1].Value = apdk_name;
                    ws.Cells[rowIndex + 0, k + colStart2].Value = am11_kind_id;
                    ws.Cells[rowIndex + 1, k + colStart2].Value = apdk_name;
                    ws.Cells[rowIndex + 0, k + colStart3].Value = am11_kind_id;
                    ws.Cells[rowIndex + 1, k + colStart3].Value = apdk_name;
                }// for (int k = 0;k < cp_max_seq_no;k++) {

                //2.6月總量/日均量--資料
                rowIndex++;
                string ymd    = "";
                string kindId = "";

                foreach (DataRow dr in dtTemp.Rows)
                {
                    string am11_ymd = dr["am11_ymd"].AsString();
                    DateTime.TryParseExact(am11_ymd, "yyyyMMdd", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out DateTime am11);
                    string am11_kind_id = dr["am11_kind_id"].AsString();
                    int    day_cnt      = dr["day_cnt"].AsInt();
                    int    dec          = (gridName == GridName.First ? 4 : 6);//小數點4位或是6位

                    if (ymd != am11_ymd)
                    {
                        //每換一個日期
                        ymd = am11_ymd;
                        rowIndex++;
                        ws.Cells[rowIndex, 0].Value = (SumType == "D" ? am11.ToString("yyyy/MM/dd") : am11_ymd);
                    }//if (ymd != am11_ymd) {

                    if (kindId != am11_kind_id)
                    {
                        //每換一個契約
                        kindId = am11_kind_id;

                        Decimal cp_grp_m_qnty   = dr["cp_grp_m_qnty"].AsDecimal();
                        Decimal cp_grp_tot_qnty = dr["cp_grp_tot_qnty"].AsDecimal();
                        Decimal groupCount      = (gridName == GridName.First ? cp_grp_m_qnty : Math.Round(cp_grp_m_qnty / day_cnt, 4, MidpointRounding.AwayFromZero));
                        Decimal groupTotalCount = (gridName == GridName.First ? cp_grp_tot_qnty : Math.Round(cp_grp_tot_qnty / day_cnt, 4, MidpointRounding.AwayFromZero));

                        ws.Cells[rowIndex, colStart2].Value = groupCount;
                        ws.Cells[rowIndex, colStart3].Value = groupTotalCount;

                        if (groupTotalCount > 0)
                        {
                            ws.Cells[rowIndex, colStart3 + cp_max_seq_no + 1].Value = Math.Round(groupCount / groupTotalCount, dec, MidpointRounding.AwayFromZero) * 100;
                        }
                        else
                        {
                            ws.Cells[rowIndex, colStart3 + cp_max_seq_no + 1].Value = 0;
                        }
                    }//if (kindId != am11_kind_id) {

                    int     li_col     = dr["seq_no"].AsInt();
                    Decimal m_qnty     = dr["m_qnty"].AsDecimal();
                    Decimal tot_qnty   = dr["tot_qnty"].AsDecimal();
                    Decimal count      = (gridName == GridName.First ? m_qnty : Math.Round(m_qnty / day_cnt, 4, MidpointRounding.AwayFromZero));
                    Decimal totalCount = (gridName == GridName.First ? tot_qnty : Math.Round(tot_qnty / day_cnt, 4, MidpointRounding.AwayFromZero));

                    ws.Cells[rowIndex, li_col + colStart1].Value = count;
                    ws.Cells[rowIndex, li_col + colStart2].Value = totalCount;
                    if (totalCount > 0)
                    {
                        ws.Cells[rowIndex, li_col + colStart3].Value = Math.Round(count / totalCount, dec, MidpointRounding.AwayFromZero) * 100;
                    }
                    else
                    {
                        ws.Cells[rowIndex, li_col + colStart3].Value = 0;
                    }
                }//foreach (DataRow dr in dtTemp.Rows) {

                return(rowIndex);
            }//protected virtual void ExportGrid(Worksheet ws, DataTable dtTemp, GridName gridName,int rowIndex,string oswGrp) {
 public override int GetHashCode()
 {
     return(GridName != null ? GridName.GetHashCode() : 0);
 }