Ejemplo n.º 1
0
        /// <summary>
        /// 提交修改
        /// </summary>
        private void SubmitForUpdateCard()
        {
            errorProvider1.Clear();
            if (txt_CardNumber.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_CardNumber, "卡号不能为空!");
                return;
            }
            List<MemberInfoModel> modelList = manager.GetModelList(" CardID='" + txt_CardNumber.Text + "' and MemberID <> "+ID+"");
            if (modelList.Count > 0)
            {
                errorProvider1.SetError(txt_CardNumber, "卡号已经存在,请更换!");
                return;
            }
            if (txt_Mail.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_Mail, "邮箱不能为空!");
                return;
            }
            if (cmb_CardType.Text.Trim() == "")
            {
                errorProvider1.SetError(cmb_CardType, "卡类别不能为空!");
                return;
            }

            if (cmb_IDType.Text.Trim() == "")
            {
                errorProvider1.SetError(cmb_IDType, "证件类型不能为空!");
                return;
            }
            if (txt_Name.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_Name, "姓名不能为空!");
                return;
            }
            if (txt_IDCard.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_IDCard, "证件号不能为空!");
                return;
            }
            if (cmb_Sex.Text.Trim() == "")
            {
                errorProvider1.SetError(cmb_Sex, "性别不能为空!");
                return;
            }

            if (cmb_CardType.SelectedValue is Int32)
            {
                CardTypeInfoModel cardtypeModel = cardTypeManager.GetModel(Convert.ToInt32(cmb_CardType.SelectedValue));
                if (cardtypeModel.TypeName.Equals("计时产品"))
                {
                    if (dtp_StartTime.Text.Trim() == "")
                    {
                        errorProvider1.SetError(dtp_StartTime, "生效日期不能为空!");
                        return;
                    }

                    if (dtp_EndTime.Text.Trim() == "")
                    {
                        errorProvider1.SetError(dtp_EndTime, "失效日期不能为空!");
                        return;
                    }
                }
                if (cardtypeModel.TypeName.Equals("计次产品"))
                {
                    if (txt_Count.Text.Trim() == "")
                    {
                        errorProvider1.SetError(txt_Count, "剩余次数不能为空!");
                        return;
                    }
                }

            }
            if (dtp_Birthday.Text.Trim() == "")
            {
                errorProvider1.SetError(dtp_Birthday, "生日不能为空!");
                return;
            }
            if (txt_Phone.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_Phone, "电话不能为空!");
                return;
            }
            if (dtp_AddTime.Text.Trim() == "")
            {
                errorProvider1.SetError(dtp_AddTime, "办理日期不能为空!");
                return;
            }
            //修改
            if (FormName.Equals("UPDATE"))
            {
                MemberInfoModel model = manager.GetModel(ID);
                model.CardID = txt_CardNumber.Text.Trim();
                model.Mail = txt_Mail.Text.Trim();
                model.CardType = cmb_CardType.Text.Trim();
                model.IDCardType = cmb_IDType.Text.Trim();
                model.Name = txt_Name.Text.Trim();
                model.IDCard = txt_IDCard.Text.Trim();
                model.Sex = cmb_Sex.Text.Trim();
                model.StartTime = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_StartTime.Text.Trim()));
                model.Birthday = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_Birthday.Text.Trim()));
                model.EndTime = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_EndTime.Text.Trim()));
                model.Phone = txt_Phone.Text.Trim();
                model.Count = txt_Count.Text.Trim();
                model.Unit = txt_Unit.Text.Trim();
                model.AddTime = CommTools.GetDateFormatStrot2(DateTime.Now);
                if (buffer != null || this.pictureBox1.Image != null)
                {
                    Image image = this.pictureBox1.Image;
                    model.Photo = CommTools.GetByteFromImage(this.pictureBox1);
                }
                //model.InfoType = "正常";
                MainForm mf = (MainForm)this.Owner;
                model.AddUserName = mf.lbl_login_name.Text.Trim().Split(':')[1];

                bool isAdd = manager.Update(model);
                MessageBox.Show("会员:" + txt_Name.Text.Trim() + " 修改" + (isAdd ==true  ? "成功!" : "失败!"));
                CommTools.AddSystemLog("修改", "会员:" + txt_Name.Text.Trim() + " 修改" + (isAdd ==true  ? "成功!" : "失败!"));

                //添加历史记录
                MemberHistoryInfoModel hisModel = new MemberHistoryInfoModel();
                hisModel.MemberID = manager.GetMaxId();
                hisModel.CardID = txt_CardNumber.Text.Trim();
                hisModel.Mail = txt_Mail.Text.Trim();
                hisModel.CardType = cmb_CardType.Text.Trim();
                hisModel.IDCardType = cmb_IDType.Text.Trim();
                hisModel.Name = txt_Name.Text.Trim();
                hisModel.IDCard = txt_IDCard.Text.Trim();
                hisModel.Sex = cmb_Sex.Text.Trim();
                hisModel.Photo = model.Photo;
                hisModel.InfoType = model.InfoType;
                hisModel.StartTime = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_StartTime.Text.Trim()));
                hisModel.Birthday = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_Birthday.Text.Trim()));
                hisModel.EndTime = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_EndTime.Text.Trim()));
                hisModel.Phone = txt_Phone.Text.Trim();
                hisModel.Count = txt_Count.Text.Trim();
                hisModel.Unit = txt_Unit.Text.Trim();
                hisModel.AddTime = CommTools.GetDateFormatStrot2(DateTime.Now);
                hisModel.AddUserName = mf.lbl_login_name.Text.Trim().Split(':')[1];
                hisModel.InfoType = "修改";
                int isAddHis = hisManager.Add(hisModel);
                this.Close();

            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 提交售卡
        /// </summary>
        private void SubmitForSellCard()
        {
            errorProvider1.Clear();
            if (txt_CardNumber.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_CardNumber, "卡号不能为空!");
                return;
            }
            List<MemberInfoModel> modelList = manager.GetModelList(" CardID='" + txt_CardNumber.Text + "'");
            if (modelList.Count > 0)
            {

                errorProvider1.SetError(txt_CardNumber, "卡号已经存在,请更换!");
                return;

            }
            //if (txt_Mail.Text.Trim() == "")
            //{
            //    errorProvider1.SetError(txt_Mail, "邮箱不能为空!");
            //    return;
            //}
            if (cmb_CardType.Text.Trim() == "")
            {
                errorProvider1.SetError(cmb_CardType, "卡类别不能为空!");
                return;
            }

            if (cmb_IDType.Text.Trim() == "")
            {
                errorProvider1.SetError(cmb_IDType, "证件类型不能为空!");
                return;
            }
            if (txt_Name.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_Name, "姓名不能为空!");
                return;
            }
            if (txt_IDCard.Text.Trim() == "")
            {
                errorProvider1.SetError(txt_IDCard, "证件号不能为空!");
                return;
            }
            if (cmb_Sex.Text.Trim() == "")
            {
                errorProvider1.SetError(cmb_Sex, "性别不能为空!");
                return;
            }

            if (cmb_CardType.SelectedValue is Int32)
            {
                CardTypeInfoModel cardtypeModel = cardTypeManager.GetModel(Convert.ToInt32(cmb_CardType.SelectedValue));
                if (cardtypeModel.TypeName.Equals("计时产品"))
                {
                    if (dtp_StartTime.Text.Trim() == "")
                    {
                        errorProvider1.SetError(dtp_StartTime, "生效日期不能为空!");
                        return;
                    }

                    if (dtp_EndTime.Text.Trim() == "")
                    {
                        errorProvider1.SetError(dtp_EndTime, "失效日期不能为空!");
                        return;
                    }
                }
                if (cardtypeModel.TypeName.Equals("计次产品"))
                {
                    if (txt_Count.Text.Trim() == "")
                    {
                        errorProvider1.SetError(txt_Count, "剩余次数不能为空!");
                        return;
                    }
                }

            }
            if (dtp_Birthday.Text.Trim() == "")
            {
                errorProvider1.SetError(dtp_Birthday, "生日不能为空!");
                return;
            }
            //if (txt_Phone.Text.Trim() == "")
            //{
            //    errorProvider1.SetError(txt_Phone, "电话不能为空!");
            //    return;
            //}
            if (dtp_AddTime.Text.Trim() == "")
            {
                errorProvider1.SetError(dtp_AddTime, "办理日期不能为空!");
                return;
            }
            //添加
            if (FormName.Equals("ADD") || FormName.Equals("CONTINUED"))
            {
                MemberInfoModel model = new MemberInfoModel();
                model.MemberID = manager.GetMaxId();
                model.CardID = txt_CardNumber.Text.Trim();
                model.Mail = txt_Mail.Text.Trim();
                model.CardType = cmb_CardType.Text.Trim();
                model.IDCardType = cmb_IDType.Text.Trim();
                model.Name = txt_Name.Text.Trim();
                model.IDCard = txt_IDCard.Text.Trim();
                model.Sex = cmb_Sex.Text.Trim();
                model.StartTime = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_StartTime.Text.Trim()));
                model.Birthday = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_Birthday.Text.Trim()));
                model.EndTime = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_EndTime.Text.Trim()));
                model.Phone = txt_Phone.Text.Trim();
                model.Count = txt_Count.Text.Trim();
                model.Unit = txt_Unit.Text.Trim();
                model.AddTime = CommTools.GetDateFormatStrot2(DateTime.Now);
                if (buffer != null || this.pictureBox1.Image!=null)
                {
                    Image image = this.pictureBox1.Image;
                    model.Photo = CommTools.GetByteFromImage(this.pictureBox1);
                }
                model.InfoType = "正常";
                MainForm mf = (MainForm)this.Owner;
                model.AddUserName = mf.lbl_login_name.Text.Trim().Split(':')[1];
                int isAdd = 0;
                switch (memberBusinessType)
                {
                        case MemberBusinessType.SellCardType:
                         isAdd= manager.Add(model);
                //MessageBox.Show("会员:" + txt_Name.Text.Trim() + " 添加" + (isAdd > 0 ? "成功!" : "失败!"));
                CommTools.AddSystemLog("添加", "会员:" + txt_Name.Text.Trim() + " 添加" + (isAdd > 0 ? "成功!" : "失败!"));
                        break;
                        case MemberBusinessType.ContinuedCardType:
                        List<MemberInfoModel> memberInfoModels = manager.GetModelList("CardID='" + model.CardID + "'");
                        if (memberInfoModels != null && memberInfoModels.Count > 0)
                        {
                            model.MemberID = memberInfoModels[0].MemberID;
                            bool isFlag = manager.Update(model);
                            if (isFlag) isAdd = 1;
                           // MessageBox.Show("会员:" + txt_Name.Text.Trim() + " 续卡" + (isAdd > 0 ? "成功!" : "失败!"));
                            CommTools.AddSystemLog("续卡", "会员:" + txt_Name.Text.Trim() + " 续卡" + (isAdd > 0 ? "成功!" : "失败!"));
                        }

                        break;
                }

                //添加历史记录
                MemberHistoryInfoModel hisModel = new MemberHistoryInfoModel();
                hisModel.MemberID = manager.GetMaxId();
                hisModel.CardID = txt_CardNumber.Text.Trim();
                hisModel.Mail = txt_Mail.Text.Trim();
                hisModel.CardType = cmb_CardType.Text.Trim();
                hisModel.IDCardType = cmb_IDType.Text.Trim();
                hisModel.Name = txt_Name.Text.Trim();
                hisModel.IDCard = txt_IDCard.Text.Trim();
                hisModel.Sex = cmb_Sex.Text.Trim();
                hisModel.Photo = model.Photo;
                hisModel.InfoType = model.InfoType;
                hisModel.StartTime = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_StartTime.Text.Trim()));
                hisModel.Birthday = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_Birthday.Text.Trim()));
                hisModel.EndTime = CommTools.GetDateFormatStrot2(Convert.ToDateTime(dtp_EndTime.Text.Trim()));
                hisModel.Phone = txt_Phone.Text.Trim();
                hisModel.Count = txt_Count.Text.Trim();
                hisModel.Unit = txt_Unit.Text.Trim();
                hisModel.AddTime = CommTools.GetDateFormatStrot2(DateTime.Now);
                hisModel.AddUserName = mf.lbl_login_name.Text.Trim().Split(':')[1];
                hisModel.InfoType = "添加";
                int isAddHis = hisManager.Add(hisModel);
                this.Close();
                //显示费用
                SellCardCastFrm sellCardCastForm = new SellCardCastFrm(model);
                sellCardCastForm.Owner = this.Owner;
                sellCardCastForm.Show();

            }
        }