コード例 #1
0
ファイル: Reports.aspx.cs プロジェクト: wangqi0314/crm-tree
    private void Remove_App(dynamic data)
    {
        var             s_o = JsonConvert.SerializeObject(data.o);
        CT_Appt_Service ap  = JsonConvert.DeserializeObject <CT_Appt_Service>(s_o);

        ap.AP_Updated_by = UserSession.User.AU_Code;
        ap.AP_Update_Dt  = DateTime.Now;
        ap.AP_Canceled   = true;
        var rows = ap.Update(new string[] {
            "AP_Canceled",
            "AP_Updated_by",
            "AP_Update_Dt"
        });

        Response.Write(JsonConvert.SerializeObject(new { isOK = rows > 0 }));
    }
コード例 #2
0
    /// <summary>
    /// 保存预约信息
    /// </summary>
    /// <param name="data"></param>
    private void Save_Appointment(dynamic data)
    {
        var db = DBCRMTree.GetInstance();

        try
        {
            var _AP_Code = -1;
            using (var tran = db.GetTransaction())
            {
                var             s  = JsonConvert.SerializeObject(data.o);
                CT_Appt_Service ap = JsonConvert.DeserializeObject <CT_Appt_Service>(s);

                var ap_code = ap.AP_Code;

                if (ap.AP_SC_Code == -1)
                {
                    ap.AP_SC_Code = null;
                }
                if (ap.AP_ST_Code == -1)
                {
                    ap.AP_ST_Code = null;
                }

                if (UserSession.User.UG_UType == 1)
                {
                    ap.AP_AD_Code = UserSession.DealerEmpl.DE_AD_OM_Code;
                }
                else
                {
                    ap.AP_AD_Code = ap.AP_AD_Code.HasValue && ap.AP_AD_Code.Value > 0 ? ap.AP_AD_Code : UserSession.DealerEmpl.DE_AD_OM_Code;
                }
                if (ap.AP_Code > 0)
                {
                    ap.AP_Updated_by = UserSession.User.AU_Code;
                    ap.AP_Update_Dt  = DateTime.Now;
                    ap.Update(new string[] {
                        //"AP_CI_Code" ,
                        "AP_AD_Code",
                        //"AP_Cont_Type" ,
                        //"AP_PL_ML_Code" ,
                        //"AP_SC_Code",
                        //"AP_ST_Code" ,
                        //"AP_MP_Code" ,
                        //"AP_PAM_Code" ,
                        "AP_Notification",
                        "AP_Time",
                        "AP_SA_Selected",
                        "AP_Transportation",
                        "AP_Updated_by",
                        "AP_Update_Dt"
                    });
                }
                else
                {
                    var ug_code = UserSession.User.AU_UG_Code;
                    if (ug_code >= 10)
                    {
                        ap.AP_PAM_Code = 1;
                    }
                    else if (ug_code == 1)
                    {
                        ap.AP_PAM_Code = 2;
                    }
                    else if (ug_code == 3)
                    {
                        ap.AP_PAM_Code = 3;
                    }
                    else if (ug_code == 4)
                    {
                        ap.AP_PAM_Code = 4;
                    }
                    else if (ug_code == 5)
                    {
                        ap.AP_PAM_Code = 5;
                    }

                    if (ap.AP_SC_Code == 1)
                    {
                        ap.AP_MP_Code = ap.AP_ST_Code;
                    }

                    ap.AP_Created_by = UserSession.User.AU_Code;
                    ap.AP_Update_Dt  = DateTime.Now;
                    ap_code          = (int)ap.Insert();
                }


                if (ap_code > 0)
                {
                    string          note = data.o.SN_Note;
                    CT_Service_Note n    = new CT_Service_Note();
                    n.SN_AP_Code = ap_code;
                    n.SN_Note    = note;
                    if (CT_Service_Note.Exists("SN_AP_Code = @0 AND ISNULL(SN_Cat,0) = 0", ap_code))
                    {
                        db.Update <CT_Service_Note>("SET [SN_Note] = @SN_Note WHERE SN_AP_Code=@SN_AP_Code AND ISNULL(SN_Cat,0) = 0", n);
                        //db.Update(@"UPDATE [CT_Service_Notes] set [SN_Note] = @SN_Note WHERE SN_AP_Code=@SN_AP_Code", n);
                    }
                    else if (!string.IsNullOrWhiteSpace(n.SN_Note))
                    {
                        n.Insert();
                    }

                    string          generalNote = data.o.EX_GeneralNote;
                    CT_Service_Note gn          = new CT_Service_Note();
                    gn.SN_AP_Code = ap_code;
                    gn.SN_Note    = generalNote;
                    gn.SN_Cat     = 1;
                    if (CT_Service_Note.Exists("SN_AP_Code = @0 AND SN_Cat = 1", ap_code))
                    {
                        db.Update <CT_Service_Note>("SET [SN_Note] = @SN_Note,SN_Cat=1 WHERE SN_AP_Code=@SN_AP_Code AND SN_Cat = 1", gn);
                    }
                    else if (!string.IsNullOrWhiteSpace(gn.SN_Note))
                    {
                        gn.Insert();
                    }
                }
                tran.Complete();
                _AP_Code = ap_code;
            }
            Response.Write(JsonConvert.SerializeObject(new { isOK = true, AP_Code = _AP_Code }));
        }
        catch (Exception ex)
        {
            db.AbortTransaction();
            Response.Write(JsonConvert.SerializeObject(new { isOK = false, msg = ex.Message }));
        }
    }