private void btView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //frm06sbxsLine frm = new frm06sbxsLine();
            //frm.orgcode = btGdsList.EditValue.ToString();
            //if (frm.ShowDialog()==DialogResult.OK)
            //{

            //    IList<sdjl_06sbxs> pj06list = new List<sdjl_06sbxs>();
            //    pj06list = Client.ClientHelper.PlatformSqlMap.GetList<sdjl_06sbxs>(" where LineName='" + frm.linename + "'");
            //    if (pj06list.Count>0)
            //    {
            //        Export06.ExportExcel(pj06list);
            //    }
            //   else
            //    {
            //        MsgBox.ShowTipMessageBox("此线路没有添加巡视情况。");
            //        return;
            //    }
            //}
            if (gridView1.FocusedRowHandle >= 0)
            {
                bool xsmxflag = false; //是否有巡视的子表
                frmExportYearSelect frm = new frmExportYearSelect();
                DataTable dt = new DataTable();
                dt.Columns.Add("A", typeof(string));
                dt.Columns.Add("B", typeof(bool));
                if (frm.ShowDialog()==DialogResult.OK)
                {
                    DataRow[] dtc = frm.DT1.Select("B=1");
                    foreach (DataRow dr1 in dtc)
                    {
                        DataRow dr = dt.NewRow();
                        dr[0] = dr1[0].ToString();
                        dr[1] = Convert.ToInt32(dr1[1]);
                        dt.Rows.Add(dr);
                    }
                    dtc = frm.DT1.Select("D=1");
                    foreach (DataRow dr1 in dtc)
                    {
                        DataRow dr = dt.NewRow();
                        dr[0] = dr1[2].ToString();
                        dr[1] = Convert.ToInt32(dr1[3]);
                        dt.Rows.Add(dr);
                    }
                    dtc = frm.DT1.Select("F=1");
                    foreach (DataRow dr1 in dtc)
                    {
                        DataRow dr = dt.NewRow();
                        dr[0] = dr1[4].ToString();
                        dr[1] = Convert.ToInt32(dr1[5]);
                        dt.Rows.Add(dr);
                    }


                    Dictionary<string, List<sdjl_06sbxs>> diclist = new Dictionary<string, List<sdjl_06sbxs>>();
                    sdjl_06sbxs _pj = gridView1.GetRow(gridView1.FocusedRowHandle) as sdjl_06sbxs;
                    //添加明细表的信息
                    IList<sdjl_06sbxsmx> ilist = null;
                    if (dt.Rows .Count== 0)
                    {
                       ilist = Client.ClientHelper.PlatformSqlMap.GetList<sdjl_06sbxsmx>(" where ParentID='" + _pj.ID + "' order by CreateDate ");
                    }
                    else
                    {
                        string sely = "(";
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (i < dt.Rows.Count - 1)
                            {
                                sely += "'" + dt.Rows[i][0].ToString() + "',";
                            }
                            else
                                sely += "'" + dt.Rows[i][0].ToString() + "')";

                        }
                        ilist = Client.ClientHelper.PlatformSqlMap.GetList<sdjl_06sbxsmx>(" where ParentID='" + _pj.ID + "'and year(xssj) in"+sely+ "order by CreateDate ");
                    }
                    if (ilist.Count == 0)
                    {
                        xsmxflag = false;
                        List<sdjl_06sbxs> lispj = new List<sdjl_06sbxs>();
                        lispj.Add(_pj);
                        diclist[_pj.LineID] = lispj;
                    }
                    else
                    {
                        xsmxflag = true;
                        List<sdjl_06sbxs> lispj = new List<sdjl_06sbxs>();
                        diclist[_pj.LineID] = lispj;
                        foreach (sdjl_06sbxsmx pmx in ilist)
                        {
                            sdjl_06sbxs newpj = new sdjl_06sbxs();
                            Type obj = newpj.GetType();
                            foreach (PropertyInfo p in obj.GetProperties())
                            {
                                try
                                {
                                    p.SetValue(newpj, pmx.GetType().GetProperty(p.Name).GetValue(pmx, null), null);
                                }
                                catch (Exception ex) { }
                            }
                            diclist[_pj.LineID].Add(newpj);
                        }
                        // lispj.Add(_pj);

                    }
                    foreach (KeyValuePair<string, List<sdjl_06sbxs>> pp in diclist)
                    {
                        List<sdjl_06sbxs> objlist = pp.Value;
                        if (objlist.Count > 0)
                        {
                            ExportSD06.ExportExcel(objlist,xsmxflag);
                        }

                    }
                }
          
                }
               

            //for (int i = 0; i < gridView1.RowCount;i++ )
            //{
            //    sdjl_06sbxs _pj = gridView1.GetRow(i) as sdjl_06sbxs;
              
            //    if (diclist.ContainsKey(_pj.LineID))
            //    {
            //        diclist[_pj.LineID].Add(_pj);
            //    }
            //    else
            //    {
            //        List<sdjl_06sbxs> lispj = new List<sdjl_06sbxs>();
            //        lispj.Add(_pj);
            //        diclist[_pj.LineID] = lispj;
            //    }
            //    //添加明细表的信息
            //    IList<sdjl_06sbxsmx> ilist = Client.ClientHelper.PlatformSqlMap.GetList<sdjl_06sbxsmx>(" where ParentID='" + _pj.ID + "' order by CreateDate desc");
            //    foreach (sdjl_06sbxsmx pmx in ilist)
            //    {
            //        sdjl_06sbxs newpj = new sdjl_06sbxs();
            //        Type obj = newpj.GetType();
            //        foreach (PropertyInfo p in obj.GetProperties())
            //        {
            //            try
            //            {
            //                p.SetValue(newpj, p.GetValue(pmx, null), null);
            //            }
            //            catch { }
            //        }
            //        diclist[_pj.LineID].Add(newpj);
            //    }
            //}
            //foreach (KeyValuePair<string, List<sdjl_06sbxs>> pp in diclist)
            //{
            //    List<sdjl_06sbxs> objlist = pp.Value;
            //    if (objlist.Count > 0)
            //    {
            //        Export06.ExportExcel(objlist);
            //    }

            //}
           
        }
Exemple #2
0
 void ucTop_FocusedRowChanged(object sender, sdjl_06sbxs obj)
 {
     ucBottom.ParentObj = obj;
     //splitCC1.Panel2.Text = "测量记录:" + (obj != null ? obj.kymc : "");
 }
 /// <summary>
 /// 新建对象设置Key值
 /// </summary>
 /// <param name="newobj"></param>
 void gridViewOperation_CreatingObjectEvent(sdjl_06sbxs newobj)
 {
     if (parentID == null) return;
     newobj.OrgCode = parentID;
     newobj.OrgName = parentObj.OrgName;
     newobj.CreateDate = DateTime.Now;
     Ebada.Core.UserBase m_UserBase = MainHelper.ValidateLogin();
     newobj.CreateMan = m_UserBase.RealName;
     newobj.xssj = DateTime.Now;
 }
Exemple #4
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cbxqx.Checked)
            {
                if (string.IsNullOrEmpty(cmbqxdj.EditValue.ToString()))
                {
                    MsgBox.ShowWarningMessageBox("请选择缺陷等级!");
                    return;
                }
            }
            else
            {
                rowData.qxdj = string.Empty;
            }
            
            sd_xl xl= Client.ClientHelper.PlatformSqlMap.GetOne<sd_xl>("where LineCode='" + rowData.c1 + "'");
            if (xl == null) 
                return;
            //添加缺陷
            sdjl_06sbxs sbxs= Client.ClientHelper.PlatformSqlMap.GetOne<sdjl_06sbxs>("where orgcode='" + rowData.c2 + "' and LineID='" + xl.LineID + "'");
            sdjl_06sbxsmx sbxsmx = new sdjl_06sbxsmx();
            string orgname = Client.ClientHelper.PlatformSqlMap.GetOne<mOrg>("where orgcode='" + rowData.c2 + "'").OrgName; 
            if (sbxs == null)
            {
                sbxs = new sdjl_06sbxs();
                sbxs.OrgCode = rowData.c2;
                sbxs.OrgName = orgname;
                sbxs.LineID = xl.LineID;
                sbxs.LineName = xl.LineName;
                sbxs.xssj = rowData.jcrq;
                sbxs.CreateDate = DateTime.Now;
                Client.ClientHelper.PlatformSqlMap.Create<sdjl_06sbxs>(sbxs);    
            }
            sbxsmx.ParentID = sbxs.ID;
            sbxsmx.OrgCode = rowData.c2;
            sbxsmx.OrgName = orgname;
            sbxsmx.LineID = xl.LineID;
            sbxsmx.LineName = xl.LineName;
            sbxsmx.qxlb = rowData.qxdj;
            sbxsmx.qxnr = rowData.jcjg;
            sbxsmx.xsr = rowData.jcr;
            sbxsmx.xssj = rowData.jcrq;
            sbxsmx.CreateDate = DateTime.Now;
            Client.ClientHelper.PlatformSqlMap.Create<sdjl_06sbxsmx>(sbxsmx);

            this.DialogResult = DialogResult.OK;
        }