public static bool insertLabel(Model.Label _u) { try { // Tao ket noi conn = new SqlConnection(strConnect); // Mo ket noi if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } // Them don vi string strCmd = string.Format("INSERT INTO NHAN_HIEU VALUES('{0}', '{1}', '{2}')", _u.IdString, _u.Name, _u.IdType); SqlCommand myCmd = new SqlCommand(strCmd, conn); SqlDataReader myReader = myCmd.ExecuteReader(); conn.Close(); conn.Dispose(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); conn.Close(); conn.Dispose(); return(false); } }
public static bool updateLabel(Model.Label _u) { try { // Tao ket noi conn = new SqlConnection(strConnect); // Mo ket noi if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } // Them nhan hieu string strCmd = string.Format("UPDATE NHAN_HIEU set TENNH = N'{0}', MALOAI = '{1}' where MANH = '{2}'", _u.Name, _u.IdType, _u.IdString); SqlCommand myCmd = new SqlCommand(strCmd, conn); SqlDataReader myReader = myCmd.ExecuteReader(); conn.Close(); conn.Dispose(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); conn.Close(); conn.Dispose(); return(false); } }
public void UpdatePost(Model.Label label, ICollection <Model.ShareRecipient> recipients, ICollection <Model.FileAsset> files) { var api = new postServiceClass() { session_token = CloudService.SessionToken, APIKEY = CloudService.APIKey, group_id = Settings.Default.GroupId }; if (recipients == null) { recipients = new List <Model.ShareRecipient>(); } if (files == null) { files = new List <Model.FileAsset>(); } // use an old last_update_time to work around cloud consistency checking var lastUpdateTime = DateTime.Now.AddMinutes(-10.0); api.UpdatePost( api.session_token, label.share_post_id, files.Select(x => x.file_id.ToString()).ToList(), lastUpdateTime, recipients.Select(x => x.email).ToList(), label.name, "" ); }
protected void btnAddClick(object sender, EventArgs e) { if (Page.IsValid) { ICollection <Model.Label> labels = new List <Model.Label>(); foreach (ListItem item in checkboxLabels.Items) { if (item.Selected) { Model.Label label = eventService.GetAllLabels().Where(x => x.labelId == Convert.ToInt32(item.Value)).Single(); labels.Add(label); } } if (Request.Params.Get("action").Equals("Add")) { eventService.AddLabel(commentId, labels); } else { eventService.RemoveLabel(commentId, labels); } /* Do action. */ String url = String.Format("~/Pages/EventPages/Home.aspx"); Response.Redirect(Response.ApplyAppPathModifier(url)); } }
protected void CreateLabelClick(object sender, EventArgs e) { if (Page.IsValid) { /* Create an Account. */ String labelName = txtLabel.Text; Model.Label label = new Model.Label(); label.name = labelName; /* Get the Service */ IIoCManager iocManager = (IIoCManager)HttpContext.Current.Application["managerIoC"]; IEventService eventService = iocManager.Resolve <IEventService>(); try { Model.Label labelCreated = eventService.Create(label); Context.Items.Add("createdGroup", labelCreated); LogManager.RecordMessage("Label " + label.name + " created.", MessageType.Info); Server.Transfer(Response.ApplyAppPathModifier("~/Pages/EventPages/Home.aspx")); } catch (DuplicateInstanceException) { Server.Transfer(Response.ApplyAppPathModifier("~/Pages/Errors/InternalError.aspx")); } } }
public void Process(Model.Label label) { var files = db.QueryLabelFiles(label); var OnCloudFiles = files.Where(x => x.on_cloud.HasValue && x.on_cloud.Value).ToList(); foreach (var file in files.Where(x => !x.on_cloud.HasValue || !x.on_cloud.Value)) { api.UploadAttachment(file); db.UpdateFileOnCloud(file); OnCloudFiles.Add(file); OnCloudFiles.Sort((x, y) => x.event_time.CompareTo(y.event_time)); api.UpdatePost(label, null, OnCloudFiles); } if (string.IsNullOrEmpty(label.share_post_id)) { api.CreatePost(label, null, files); } else { api.UpdatePost(label, null, files); } db.UpdateShareComplete(label); }
private long getOldLabelSeq(Model.Label label) { var oldSeq = ctx.labels_from_seq; if (label_seq.ContainsKey(label.label_id)) { oldSeq = label_seq[label.label_id]; } return(oldSeq); }
public ICollection <Model.ShareRecipient> QueryRecipients(Model.Label label) { using (var db = new MyDbContext()) { var q = from r in db.Object.ShareRecipients where r.label_id == label.label_id select r; return(q.ToList()); } }
private void setOldLabelSeq(Model.Label label) { if (!label_seq.ContainsKey(label.label_id)) { label_seq.Add(label.label_id, label.seq); } else { label_seq[label.label_id] = label.seq; } }
private void Delselectitem_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; int lid = Convert.ToInt32(button.Tag); Model.Label content = selectlabels.Where(p => p.Labelid == lid).FirstOrDefault(); selectlabels.Remove(content); labels.Add(content); Haveselect.ItemsSource = selectlabels; buttons = GetChildObjects <Button>(Labellist); buttons.ForEach(p => p.IsEnabled = true); }
public ICollection <Model.FileAsset> QueryLabelFiles(Model.Label label) { using (var db = new MyDbContext()) { var q = from lf in db.Object.LabelFiles join f in db.Object.Files on lf.file_id equals f.file_id join lb in db.Object.Labels on lf.label_id equals lb.label_id where !f.deleted && lb.label_id == label.label_id orderby f.event_time ascending select f; return(q.ToList()); } }
private void btnAdd_Click(object sender, EventArgs e) { Model.Label u = new Model.Label(txtID.Text, txtName.Text, cbType.SelectedValue.ToString(), cbType.Text); if (Controller.Connector.insertLabel(u)) { MessageBox.Show("Thêm mới thành công nhãn hiệu " + txtID.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm mới thành công nhãn hiệu " + txtID.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.Close(); }
public void UpdateShareComplete(Model.Label label) { using (var db = new SQLiteConnection(MyDbContext.ConnectionString)) { db.Open(); using (var cmd = db.CreateCommand()) { cmd.CommandText = "update [Labels] set share_proc_seq = @seq where label_id = @label"; cmd.Parameters.Add(new SQLiteParameter("@seq", (object)label.seq)); cmd.Parameters.Add(new SQLiteParameter("@label", label.label_id)); cmd.ExecuteNonQuery(); } } }
private void Parse(string value) { if (value.Contains(",")) { var item = new Model.Label(); if (value.Contains("-")) { item.SignBit = true; // If the label includes "-", the value is negative } string[] array = value.Split('%'); // Split the comments string[] subArray = array[0].Trim().Split(','); // Split the labels item.Name = subArray[0]; // item.Name = Label name string[] subSubArray = subArray[1].Trim().Split(' '); // subSubArray = the base of the label's value if (subSubArray[0] == "BIN" || subSubArray[0] == "DEC" || subSubArray[0] == "HEX" || subSubArray[0] == "OCT") { item.isValue = true; // Not a loop label if (subSubArray[0] == "BIN") { item.Value = convert(subSubArray[1], 2, 2); item.Value = completeData(4, item.Value); } else // Convert all the base types to binary { if (subSubArray[0] == "OCT") { item.Value = convert(subSubArray[1].Replace("-", ""), 8, 2); } if (subSubArray[0] == "DEC") { item.Value = convert(subSubArray[1].Replace("-", ""), 10, 2); } if (subSubArray[0] == "HEX") { item.Value = convert(subSubArray[1].Replace("-", ""), 16, 2); } if (item.SignBit == true) // If negative { item.Value = completeData(3, item.Value); char[] temp = new char[item.Value.Length]; for (int i = 0; i < item.Value.Length; i++) // Complement { if (item.Value[i] == '0') { temp[i] = '1'; } if (item.Value[i] == '1') { temp[i] = '0'; } } string _temp = new string(temp); int num = Convert.ToInt32(convert(_temp, 2, 10)) + 1; // Two's Complement _temp = ""; _temp = convert(num.ToString(), 10, 2); _temp = completeData(3, _temp); item.Value = string.Concat("1", _temp); // Add 1 as the sign bit (4th bit) } } item.Base = 2; } else // Loop label { assemblyCodeList.Add(subArray[1].Trim()); item.Value = "0000"; item.Base = 2; item.isValue = false; } labelList.Add(item); } else // No label { string[] array = value.Split('%'); assemblyCodeList.Add(array[0].Trim()); } }
public void Process(Model.Label label) { var db = new ShareEnableTaskDB(); db.UpdateShareComplete(label); }
public void CreatePost(Model.Label label, ICollection <Model.ShareRecipient> recipients, ICollection <Model.FileAsset> files) { throw new NotImplementedException(); }
private void Parse(string value) { if (value.Contains(",")) { var item = new Model.Label(); if (value.Contains("-")) { item.SignBit = true; } string[] array = value.Split('%'); string[] subArray = array[0].Trim().Split(','); item.Name = subArray[0]; string[] subSubArray = subArray[1].Trim().Split(' '); if (subSubArray[0] == "BIN" || subSubArray[0] == "DEC" || subSubArray[0] == "HEX" || subSubArray[0] == "OCT") { item.isValue = true; if (subSubArray[0] == "BIN") { item.Value = convert(subSubArray[1], 2, 2); item.Value = completeData(4, item.Value); } else { if (subSubArray[0] == "OCT") { item.Value = convert(subSubArray[1].Replace("-", ""), 8, 2); } if (subSubArray[0] == "DEC") { item.Value = convert(subSubArray[1].Replace("-", ""), 10, 2); } if (subSubArray[0] == "HEX") { item.Value = convert(subSubArray[1].Replace("-", ""), 16, 2); } if (item.SignBit == true) { item.Value = completeData(3, item.Value); char[] temp = new char[item.Value.Length]; for (int i = 0; i < item.Value.Length; i++) { if (item.Value[i] == '0') { temp[i] = '1'; } if (item.Value[i] == '1') { temp[i] = '0'; } } string _temp = new string(temp); int num = Convert.ToInt32(convert(_temp, 2, 10)) + 1; _temp = ""; _temp = convert(num.ToString(), 10, 2); _temp = completeData(3, _temp); item.Value = string.Concat("1", _temp); } } item.Base = 2; } else { assemblyCodeList.Add(subArray[1].Trim()); item.Value = "0000"; item.Base = 2; item.isValue = false; } labelList.Add(item); } else { string[] array = value.Split('%'); assemblyCodeList.Add(array[0].Trim()); } }