Exemplo n.º 1
0
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=salesman>salesman</param>
 /// <param name=actiondate>actiondate</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of crmactionschedule</returns>
 public modCrmActionSchedule GetItem(string salesman, DateTime actiondate, out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = string.Format("select action_man,action_date,action_content,status,status_desc,update_user,update_time from crm_action_schedule where action_man='{0}' and action_date='{1}' order by action_man,action_date", salesman, actiondate);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modCrmActionSchedule model = new modCrmActionSchedule();
                 model.ActionMan     = dalUtility.ConvertToString(rdr["action_man"]);
                 model.ActionDate    = dalUtility.ConvertToDateTime(rdr["action_date"]);
                 model.ActionContent = dalUtility.ConvertToString(rdr["action_content"]);
                 model.Status        = dalUtility.ConvertToInt(rdr["status"]);
                 model.StatusDesc    = dalUtility.ConvertToString(rdr["status_desc"]);
                 model.UpdateUser    = dalUtility.ConvertToString(rdr["update_user"]);
                 model.UpdateTime    = dalUtility.ConvertToDateTime(rdr["update_time"]);
                 emsg = null;
                 return(model);
             }
             else
             {
                 emsg = "Error on read data";
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// get all crmactionschedule
        /// <summary>
        /// <param name=statuslist>statuslist</param>
        /// <param name=salesman>salesman</param>
        /// <param name=fromdate>fromdate</param>
        /// <param name=todate>todate</param>
        /// <param name=out emsg>return error message</param>
        ///<returns>details of all crmactionschedule</returns>
        public BindingCollection <modCrmActionSchedule> GetIList(string statuslist, string salesman, string fromdate, string todate, out string emsg)
        {
            try
            {
                BindingCollection <modCrmActionSchedule> modellist = new BindingCollection <modCrmActionSchedule>();
                string statuswhere = string.Empty;
                if (!string.IsNullOrEmpty(statuslist) && statuslist.CompareTo("ALL") != 0)
                {
                    statuswhere = "and status in ('" + statuslist.Replace(",", "','") + "') ";
                }

                string actiondatewhere = string.Empty;
                if (!string.IsNullOrEmpty(fromdate))
                {
                    actiondatewhere = "and action_date >= '" + Convert.ToDateTime(fromdate) + "' ";
                }
                if (!string.IsNullOrEmpty(todate))
                {
                    actiondatewhere += "and action_date <= '" + Convert.ToDateTime(todate) + "' ";
                }
                //Execute a query to read the categories
                string sql = string.Format("select action_man,action_date,action_content,status,status_desc,update_user,update_time "
                                           + "from crm_action_schedule where action_man='{0}' " + statuswhere + actiondatewhere + "order by action_man,action_date", salesman);
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
                {
                    while (rdr.Read())
                    {
                        modCrmActionSchedule model = new modCrmActionSchedule();
                        model.ActionMan     = dalUtility.ConvertToString(rdr["action_man"]);
                        model.ActionDate    = dalUtility.ConvertToDateTime(rdr["action_date"]);
                        model.ActionContent = dalUtility.ConvertToString(rdr["action_content"]);
                        model.Status        = dalUtility.ConvertToInt(rdr["status"]);
                        model.StatusDesc    = dalUtility.ConvertToString(rdr["status_desc"]);
                        model.UpdateUser    = dalUtility.ConvertToString(rdr["update_user"]);
                        model.UpdateTime    = dalUtility.ConvertToDateTime(rdr["update_time"]);
                        modellist.Add(model);
                    }
                }
                emsg = null;
                return(modellist);
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// insert a crmactionschedule
        /// <summary>
        /// <param name=mod>model object of crmactionschedule</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Insert(modCrmActionSchedule mod, out string emsg)
        {
            try
            {
                dalUserList dalu    = new dalUserList();
                DateTime    svrtime = dalu.GetServerTime(out emsg);
                TimeSpan    ts1     = new TimeSpan(svrtime.Ticks);
                TimeSpan    ts2     = new TimeSpan(mod.ActionDate.Ticks);
                TimeSpan    ts      = ts2.Subtract(ts1).Duration();
                if (ts.Days < 0)
                {
                    emsg = "您不能新增过去的工作计划!";
                    return(false);
                }
                dalSysParameters dalp = new dalSysParameters();
                int aheaddays         = Convert.ToInt32(dalp.GetParaValue("ACTION_SCHEDULE_AHEAD_DAYS"));
                if (ts.Days > aheaddays)
                {
                    emsg = "您不能提交" + aheaddays.ToString() + "天后的工作计划";
                    return(false);
                }

                string sql = string.Format("insert into crm_action_schedule(action_man,action_date,action_content,status,status_desc,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}',getdate())", mod.ActionMan, mod.ActionDate, mod.ActionContent, mod.Status, mod.StatusDesc, mod.UpdateUser);
                int    i   = SqlHelper.ExecuteNonQuery(sql);
                if (i > 0)
                {
                    emsg = null;
                    return(true);
                }
                else
                {
                    emsg = "Unknown error when ExecuteNonQuery!";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
        }
Exemplo n.º 4
0
        public void InitData(modCrmActionSchedule mod)
        {
            txtActionMan.Text     = mod.ActionMan;
            txtActionContent.Text = mod.ActionContent;
            txtActionDate.Text    = mod.ActionDate.ToString("yyyy-MM-dd");
            txtStatusDesc.Text    = mod.StatusDesc;
            switch (mod.Status)
            {
            case 0:
                rbActive.Checked = true;
                break;

            case 1:
                rbCompleted.Checked = true;
                break;

            case 7:
                rbCancelled.Checked = true;
                break;
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// delete a crmactionschedule
 /// <summary>
 /// <param name=salesman>salesman</param>
 /// <param name=actiondate>actiondate</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Delete(string salesman, DateTime actiondate, out string emsg)
 {
     try
     {
         modCrmActionSchedule mod = GetItem(salesman, actiondate, out emsg);
         if (mod == null)
         {
             emsg = null;
             return(true);
         }
         dalUserList dalu    = new dalUserList();
         DateTime    svrtime = dalu.GetServerTime(out emsg);
         TimeSpan    ts1     = new TimeSpan(svrtime.Ticks);
         TimeSpan    ts2     = new TimeSpan(mod.ActionDate.Ticks);
         TimeSpan    ts      = ts1.Subtract(ts2).Duration();
         if (ts.Days > 0)
         {
             emsg = "您不能删除过去的工作计划!";
             return(false);
         }
         string sql = string.Format("delete crm_action_schedule where action_man='{0}' and action_date='{1}' ", salesman, actiondate);
         int    i   = SqlHelper.ExecuteNonQuery(sql);
         if (i > 0)
         {
             emsg = null;
             return(true);
         }
         else
         {
             emsg = "Unknown error when ExecuteNonQuery!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(false);
     }
 }
Exemplo n.º 6
0
        private void EditScheduleStatus(ref modCrmActionSchedule mod, ref TextBox txt)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                EditActionScheduleStatus frm = new EditActionScheduleStatus();
                frm.InitData(mod);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    txt.ReadOnly = mod.Status == 0 ? false : true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 7
0
 private void menuStatus_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         TextBox txt = (TextBox)contextMenuStrip1.SourceControl;
         dalCrmActionSchedule dal = new dalCrmActionSchedule();
         modCrmActionSchedule mod = dal.GetItem(txtSalesMan.Text, DateTime.Parse(txt.Tag.ToString()), out Util.emsg);
         EditScheduleStatus(ref mod, ref txt);
         mod = dal.GetItem(txtSalesMan.Text, DateTime.Parse(txt.Tag.ToString()), out Util.emsg);
         if (mod.Status == 0)
         {
             txt.ReadOnly  = false;
             txt.ForeColor = Color.Black;
         }
         else if (mod.Status == 1)
         {
             txt.ReadOnly  = true;
             txt.ForeColor = Color.DarkGoldenrod;
         }
         else
         {
             txt.ReadOnly  = true;
             txt.ForeColor = Color.DarkGray;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Exemplo n.º 8
0
 private void txtContent_Validated(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         TextBox txt = (TextBox)sender;
         if (!txt.ReadOnly && rbSchedule.Checked)
         {
             dalCrmActionSchedule dal = new dalCrmActionSchedule();
             if (!dal.Exists(txtSalesMan.Text, Convert.ToDateTime(txt.Tag.ToString()), txt.Text.Trim(), out Util.emsg))
             {
                 bool ret = dal.Delete(txtSalesMan.Text.Trim(), Convert.ToDateTime(txt.Tag.ToString()), out Util.emsg);
                 if (ret)
                 {
                     if (!string.IsNullOrEmpty(txt.Text.Trim()))
                     {
                         modCrmActionSchedule mod = new modCrmActionSchedule();
                         mod.ActionMan     = txtSalesMan.Text.Trim();
                         mod.ActionDate    = Convert.ToDateTime(txt.Tag.ToString());
                         mod.ActionContent = txt.Text.Trim();
                         mod.Status        = 0;
                         mod.UpdateUser    = Util.UserId;
                         ret = dal.Insert(mod, out Util.emsg);
                         if (!ret)
                         {
                             MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                         }
                         else
                         {
                             float fontsize = txt.Font.Size;
                             txt.Font = new Font(txt.Font.FontFamily, 16, txt.Font.Style);
                             txt.Refresh();
                             Thread.Sleep(200);
                             txt.Font = new Font(txt.Font.FontFamily, fontsize, txt.Font.Style);
                             txt.Refresh();
                             txt.ReadOnly         = false;
                             txt.ContextMenuStrip = contextMenuStrip1;
                         }
                     }
                     else
                     {
                         txt.ContextMenuStrip = null;
                     }
                 }
                 else
                 {
                     MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }