Exemplo n.º 1
0
        public int SaveTemplate(Template template)
        {
            int printsettingId = -1;

            if (template.PrintSetting != null)
            {
                printsettingId = dataManager.UpDatePrintSetting(template.PrintSetting.PrintSettingId, template.PrintSetting.PrintModule, template.PrintSetting.SettingFile);
            }
            template.TemplateId = dataManager.UpdateTemplate(template.Name, template.TemplateId, TemplateTypeHelp.GetTemplateString(template.Template_Type), ConvertImage(template.Background.BgImage), template.Background.ImageHeight, template.Background.ImageWidth, printsettingId);
            for (int i = 0; i < template.Face.Items.Count; i++)
            {
                TemplateFaceItem item = template.Face.Items[i];
                if (item.Status == TemplateItemStatus.New)
                {
                    dataManager.InsertTemplateItem(item.TemplateItemId, item.Name, item.Description, item.ItemFont, item.ItemColor,
                                                   item.XAxis, item.YAxis, item.Itemtype, template.TemplateId);
                }
                else if (item.Status == TemplateItemStatus.Edit)
                {
                    dataManager.UpdateTemplateItem(item.TemplateItemId, item.Name, item.Description, item.ItemFont, item.ItemColor,
                                                   item.XAxis, item.YAxis, item.Itemtype, template.TemplateId);
                }
                else if (item.Status == TemplateItemStatus.Delete)
                {
                    dataManager.DeleteTemplateItem(item.TemplateItemId);
                }
            }
            return(template.TemplateId);
        }
Exemplo n.º 2
0
 public void DeleteItem(TemplateFaceItem item)
 {
     item.Status = TemplateItemStatus.Delete;
     if (item.TemplateItemId == -1)
     {
         list.Remove(item);
     }
 }
Exemplo n.º 3
0
 internal void AddNormalItem(TemplateFaceItem item)
 {
     if (item.TemplateItemId != -1)
     {
         list.Add(item);
         item.Status = TemplateItemStatus.Normal;
     }
 }
Exemplo n.º 4
0
        private string ReadTemplateFaceItem(StreamReader reader, ref Template template)
        {
            string           text = "";
            TemplateFaceItem item = new TemplateFaceItem();

            while ((text = reader.ReadLine()) != null)
            {
                if (text.StartsWith("TemplateItemId="))
                {
                    item.TemplateItemId = Convert.ToInt32(GetValue(text));
                }
                if (text.StartsWith("Name="))
                {
                    item.Name = GetValue(text);
                }
                if (text.StartsWith("XAxis="))
                {
                    item.XAxis = Convert.ToInt32(GetValue(text));
                }
                if (text.StartsWith("YAxis="))
                {
                    item.YAxis = Convert.ToInt32(GetValue(text));
                }
                if (text.StartsWith("ItemFont="))
                {
                    item.ItemFont = new System.Drawing.Font(GetValue(text), 8);
                }
                if (text.StartsWith("ItemFontSize="))
                {
                    item.ItemFont = new System.Drawing.Font(item.ItemFont.FontFamily.Name, Convert.ToInt32(GetValue(text)));
                }
                if (text.StartsWith("ItemColor="))
                {
                    string   rgb  = GetValue(text);
                    string[] rgbs = rgb.Split(new char[] { ' ' });
                    item.ItemColor = Color.FromArgb(Convert.ToInt32(rgbs[0]), Convert.ToInt32(rgbs[1]), Convert.ToInt32(rgbs[2]));
                }
                if (text.StartsWith("Description="))
                {
                    item.Description = GetValue(text);
                }
                if (text.StartsWith("Itemtype="))
                {
                    item.Itemtype = GetValue(text);
                }
                if (text.StartsWith("[") && text.EndsWith("]"))
                {
                    template.Face.Items.AddNormalItem(item);
                    return(text);
                }
            }
            return("");
        }
Exemplo n.º 5
0
        public TemplateFaceItem EditItem(TemplateFaceItem item)
        {
            int i = list.IndexOf(item);
            TemplateFaceItem newItem = list[i];

            newItem.Status = TemplateItemStatus.Edit;
            if (item.TemplateItemId == -1)
            {
                newItem.Status = TemplateItemStatus.New;
            }
            return(newItem);
        }
Exemplo n.º 6
0
        public IList <Template> GetAllTemplate()
        {
            IList <Template> templates = new List <Template>();
            DataTable        dt        = dataManager.GetAllCommonTemplate();

            foreach (DataRow row in dt.Rows)
            {
                Template tempTemplate = new Template(-1);
                tempTemplate.Name       = row["TemplateName"].ToString();
                tempTemplate.TemplateId = Convert.ToInt32(row["TemplateId"]);
                //byte[] imageString = (byte[])row["BgImage"];
                byte[] imageByte = dataManager.GetImageBytesById(tempTemplate.TemplateId);
                if (imageByte != null)
                {
                    MemoryStream ms = new MemoryStream(imageByte);
                    tempTemplate.Background.BgImage = Image.FromStream(ms, true);
                    if (row["bgWidth"] == null)
                    {
                        tempTemplate.Background.ImageWidth = tempTemplate.Background.BgImage.Width;
                    }
                    else
                    {
                        tempTemplate.Background.ImageWidth = Convert.ToInt32(row["bgWidth"]);
                    }
                    if (row["bgHeight"] == null)
                    {
                        tempTemplate.Background.ImageHeight = tempTemplate.Background.BgImage.Height;
                    }
                    else
                    {
                        tempTemplate.Background.ImageHeight = Convert.ToInt32(row["bgHeight"]);
                    }
                    DataTable dt2 = dataManager.GetTemplateItemById(tempTemplate.TemplateId);
                    foreach (DataRow row2 in dt2.Rows)
                    {
                        TemplateFaceItem item = new TemplateFaceItem();
                        item.TemplateItemId = Convert.ToInt32(row2["TemplateItemId"]);
                        item.Name           = row2["TemplateItemName"].ToString();
                        item.XAxis          = Convert.ToInt32(row2["xAxis"]);
                        item.YAxis          = Convert.ToInt32(row2["yAxis"]);
                        item.Description    = row2["description"].ToString();
                        item.Itemtype       = row2["dataItem"].ToString();
                        string   rgb  = row2["fontcolour"].ToString();
                        string[] rgbs = rgb.Split(new char[] { ' ' });
                        item.ItemColor = Color.FromArgb(Convert.ToInt32(rgbs[0]), Convert.ToInt32(rgbs[1]), Convert.ToInt32(rgbs[2]));
                        item.ItemFont  = new Font(row2["font"].ToString(), Convert.ToInt32(row2["fontSize"]));
                        tempTemplate.Face.Items.AddNormalItem(item);
                    }
                    if (row["printSettingId"] != DBNull.Value)
                    {
                        int       printSettingId = Convert.ToInt32(row["printSettingId"]);
                        DataTable pdt            = dataManager.GetPrintSettingById(printSettingId);
                        if (pdt.Rows.Count != 0)
                        {
                            DataRow      row1 = pdt.Rows[0];
                            PrintSetting ps   = new PrintSetting();
                            ps.PrintSettingId         = Convert.ToInt32(row1["printSettingId"]);
                            ps.PrintModule            = row1["printModel"] == null ? "" : row1["printModel"].ToString();
                            ps.SettingFile            = row1["settingfile"] == null ? "" : row1["settingfile"].ToString();
                            tempTemplate.PrintSetting = ps;
                        }
                    }
                    tempTemplate.Template_Type = TemplateTypeHelp.GetTemplateString(row["TemplateType"].ToString());
                }
                templates.Add(tempTemplate);
            }

            return(templates);
        }
Exemplo n.º 7
0
 public void AddItem(TemplateFaceItem item)
 {
     list.Add(item);
     item.Status = TemplateItemStatus.New;
 }