Esempio n. 1
0
    public void PlaceAdd()
    {
        if (cbbplace.SelectedIndex == -1)
        {
            Ext.Msg.Alert("提示", "请选择地点!").Show();
            return;
        }
        RowSelectionModel sm = this.GridPanel1.SelectionModel.Primary as RowSelectionModel;
        var     detail       = dc.YPlanplace.Where(p => p.Ctid == Decimal.Parse(sm.SelectedRecordID)).OrderByDescending(p => p.Moveorder);
        decimal index        = 1;

        if (detail.Count() > 0)
        {
            //foreach (var r in detail)
            //{
            //    index = r.Moveorder.Value + 1;
            //    break;
            //}
            index = (from d in detail
                     select d.Moveorder).Max().Value + 1;
        }
        YPlanplace pp = new YPlanplace
        {
            Recordtime = DateTime.Now,
            Placeid    = decimal.Parse(cbbplace.SelectedItem.Value),
            Moveorder  = index,
            Ctid       = Decimal.Parse(sm.SelectedRecordID)
        };

        //dc.YPlanplace.InsertOnSubmit(pp);
        try
        {
            HBBLL hb = new HBBLL();
            hb.AddYPlanplace(pp.Recordtime, pp.Placeid, pp.Moveorder.Value, pp.Ctid);
            //dc.SubmitChanges();
        }
        catch (Exception ex)
        {
            Ext.Msg.Alert("错误", ex.Message).Show();
            return;
        }
        RecordAction(Decimal.Parse(sm.SelectedRecordID), "添加地点");
        cbbplace.Value = null;
        Ext.Msg.Alert("提示", "添加成功!").Show();
        PlanPlaceStoreLoad(Decimal.Parse(sm.SelectedRecordID));
    }
Esempio n. 2
0
 public string BaseSave()
 {
     if (df_begin.SelectedValue == null || cbbBc.SelectedIndex == -1 || cbbPerson.SelectedIndex == -1)
     {
         //Ext.Msg.Alert("提示", "请填写完整信息!").Show();
         return("请填写完整信息!");
     }
     if (df_begin.SelectedDate < System.DateTime.Today)
     {
         //Ext.Msg.Alert("提示", "只能制定本日及以后的计划!").Show();
         return("只能制定本日及以后的计划!");
     }
     if (dc.YChargetable.Where(p => p.Cdate == df_begin.SelectedDate && p.Cbanci == cbbBc.SelectedItem.Value && p.Cperson == cbbPerson.SelectedItem.Value).Count() > 0)
     {
         //Ext.Msg.Alert("提示", "已添加的计划!").Show();
         return("已添加的计划!");
     }
     if (cboPlaceTemplate.SelectedIndex <= -1)
     {
         YChargetable ct = new YChargetable
         {
             Recordtime = System.DateTime.Now,
             Rperson    = SessionBox.GetUserSession().PersonNumber,
             Cdate      = df_begin.SelectedDate,
             Cbanci     = cbbBc.SelectedItem.Value,
             Cperson    = cbbPerson.SelectedItem.Value,
             Maindept   = SessionBox.GetUserSession().DeptNumber,
             Status     = 1
         };
         dc.YChargetable.InsertOnSubmit(ct);
         dc.SubmitChanges();
         //RecordAction(ct.Id, "新增");
         //Ext.Msg.Alert("提示", "新增成功!").Show();
         Ext.DoScript("#{Store1}.reload();");
         return("新增成功!");
     }
     else if (cboPlaceTemplate.SelectedItem.Value != "-1")
     {
         HBBLL hb = new HBBLL();
         if (hb.HaveMoveTemplate(int.Parse(cboPlaceTemplate.SelectedItem.Value)) > 0)
         {
             DateTime     dt = System.DateTime.Now;
             YChargetable ct = new YChargetable
             {
                 Recordtime = dt,
                 Rperson    = SessionBox.GetUserSession().PersonNumber,
                 Cdate      = df_begin.SelectedDate,
                 Cbanci     = cbbBc.SelectedItem.Value,
                 Cperson    = cbbPerson.SelectedItem.Value,
                 Maindept   = SessionBox.GetUserSession().DeptNumber,
                 Status     = 1
             };
             dc.YChargetable.InsertOnSubmit(ct);
             dc.SubmitChanges();
             foreach (YPPTDetail pt in hb.GetYPPTDetail(int.Parse(cboPlaceTemplate.SelectedItem.Value), "", SessionBox.GetUserSession().DeptNumber, ""))
             {
                 YPlanplace pp = new YPlanplace
                 {
                     Ctid       = ct.Id,
                     Recordtime = dt,
                     Placeid    = decimal.Parse(pt.PlaceId.ToString()),
                     Moveorder  = decimal.Parse(pt.MoveOrder.ToString())
                 };
                 hb.AddYPlanplace(pp.Recordtime, pp.Placeid, pp.Moveorder.Value, pp.Ctid);
                 //dc.YPlanplace.InsertOnSubmit(pp);
                 //dc.SubmitChanges();
             }
             //RecordAction(ct.Id, "新增");
             //RecordAction(ct.Id, "添加地点");
             //Ext.Msg.Alert("提示", "新增成功!").Show();
             //storeload();
             Ext.DoScript("#{Store1}.reload();");
             return("新增成功!");
         }
         else
         {
             //Ext.Msg.Alert("提示", "请确保模板里有走动线路!").Show();
             return("请确保模板里有走动线路!");
         }
     }
     else
     {
         //Ext.Msg.Alert("提示", "未知错误!").Show();
         return("未知错误!");
     }
 }