Exemple #1
0
    public void AddHaz()
    {
        RowSelectionModel sm  = GridPanel1.SelectionModel.Primary as RowSelectionModel;
        RowSelectionModel sm1 = GridPanel3.SelectionModel.Primary as RowSelectionModel;
        var yh = dc.Yhbase.First(p => p.Yhid == decimal.Parse(sm1.SelectedRow.RecordID));

        if (sm.SelectedRows.Count() > 0)
        {
            int i = 0;
            foreach (var r in sm.SelectedRows)
            {
                if (dc.Yhmatchup.Count(p => p.Yhid == yh.Yhid && p.Hazardsid == decimal.Parse(r.RecordID)) == 0)
                {
                    Yhmatchup ym = new Yhmatchup
                    {
                        Yhid      = yh.Yhid,
                        Hazardsid = decimal.Parse(r.RecordID)
                    };
                    DBSCMDataContext dc1 = new DBSCMDataContext();
                    dc1.Yhmatchup.InsertOnSubmit(ym);
                    dc1.SubmitChanges();
                    i++;
                }
            }
            Ext.Msg.Alert("提示", "添加成功,共计添加" + i.ToString() + "条危险源!").Show();
            SearchBLLoad();
            hazWindow.Hide();
        }
    }
Exemple #2
0
    protected void SubmitData(object sender, StoreSubmitDataEventArgs e)
    {
        XmlNode     xml      = e.Xml;
        XmlNode     rxml     = xml.SelectSingleNode("records");
        XmlNodeList uRecords = rxml.SelectNodes("record");

        if (uRecords.Count > 0)
        {
            decimal[] Yh = new decimal[uRecords.Count]; int i = 0;
            foreach (XmlNode record in uRecords)
            {
                if (record != null)
                {
                    Yh[i] = decimal.Parse(record.SelectSingleNode("Yhid").InnerText.Trim());
                    i++;
                }
            }
            var deldata = dc.Yhmatchup.Where(p => Yh.Contains(p.Yhid));
            dc.Yhmatchup.DeleteAllOnSubmit(deldata);
            dc.SubmitChanges();
            foreach (XmlNode record in uRecords)
            {
                if (record != null)
                {
                    DBSCMDataContext db = new DBSCMDataContext();
                    Yhmatchup        ym = new Yhmatchup
                    {
                        Yhid      = decimal.Parse(record.SelectSingleNode("Yhid").InnerText.Trim()),
                        Hazardsid = decimal.Parse(record.SelectSingleNode("Hazardsid").InnerText.Trim())
                    };
                    db.Yhmatchup.InsertOnSubmit(ym);
                    db.SubmitChanges();
                }
            }
            Ext.Msg.Alert("提示", "对应成功!").Show();
        }
        else
        {
            Ext.Msg.Alert("提示", "请选择需要对应的信息!").Show();
        }
    }